Compare commits

...

2 Commits

Author SHA1 Message Date
Ettore Perazzoli
4c8e80efed Fix the capplet's Makefile so that it does not include installed GNOME
VFS header files.
2000-08-12 02:17:03 +00:00
Robin Slomkowski
c5f862ea35 fixed lost header 2000-08-09 17:13:37 +00:00
132 changed files with 2 additions and 67960 deletions

View File

@@ -1,30 +0,0 @@
ABOUT-NLS
.new.ltmain.sh
Makefile
Makefile.in
aclocal.m4
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
configure.scan
intl
libtool
ltconfig
ltmain.sh
missing
mkinstalldirs
COPYING
install-sh
stamp-h
stamp-h.in
version.h
intl
macros
INSTALL
control-center.spec
my_control_center_idl

View File

@@ -1 +0,0 @@
Jonathan Blandford <jrb@redhat.com>

1540
ChangeLog

File diff suppressed because it is too large Load Diff

View File

View File

@@ -1,15 +0,0 @@
always_built_SUBDIRS = control-center capplets idl
SUBDIRS = intl po \
$(always_built_SUBDIRS)
#DIST_SUBDIRS = intl po macros $(always_built_SUBDIRS)
EXTRA_DIST = control-center.spec.in
dist-hook: control-center.spec
cp control-center.spec $(distdir)

1
NEWS
View File

@@ -1 +0,0 @@
First split version of this package

8
README
View File

@@ -1,8 +0,0 @@
Control-Center
--------------
To install this package, you need to install (at minimum):
ORBit
gnome-libs
esd

View File

@@ -1,22 +0,0 @@
#undef ENABLE_NLS
#undef HAVE_CATGETS
#undef HAVE_DEVGTK
#undef HAVE_GETTEXT
#undef HAVE_LC_MESSAGES
#undef HAVE_STPCPY
#undef HAVE_LIBSM
#undef HAVE_PROGRAM_INVOCATION_SHORT_NAME
#undef HAVE_PROGRAM_INVOCATION_NAME
#undef PACKAGE
#undef VERSION
#undef HAVE_ESD
#undef HAVE_LIBESD
/* Define if there is no `u_int64_t' and `int64_t'. */
#undef u_int64_t
#undef int64_t
#undef HAVE_DEVGTK
#undef WITH_SYMBOL_UNDERSCORE

View File

@@ -1,164 +0,0 @@
# Configure paths for ESD
# Manish Singh 98-9-30
# stolen back from Frank Belew
# stolen from Manish Singh
# Shamelessly stolen from Owen Taylor
dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
dnl
AC_DEFUN(AM_PATH_ESD,
[dnl
dnl Get the cflags and libraries from the esd-config script
dnl
AC_ARG_WITH(esd-prefix,[ --with-esd-prefix=PFX Prefix where ESD is installed (optional)],
esd_prefix="$withval", esd_prefix="")
AC_ARG_WITH(esd-exec-prefix,[ --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)],
esd_exec_prefix="$withval", esd_exec_prefix="")
AC_ARG_ENABLE(esdtest, [ --disable-esdtest Do not try to compile and run a test ESD program],
, enable_esdtest=yes)
if test x$esd_exec_prefix != x ; then
esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
if test x${ESD_CONFIG+set} != xset ; then
ESD_CONFIG=$esd_exec_prefix/bin/esd-config
fi
fi
if test x$esd_prefix != x ; then
esd_args="$esd_args --prefix=$esd_prefix"
if test x${ESD_CONFIG+set} != xset ; then
ESD_CONFIG=$esd_prefix/bin/esd-config
fi
fi
AC_PATH_PROG(ESD_CONFIG, esd-config, no)
min_esd_version=ifelse([$1], ,0.2.5,$1)
AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
no_esd=""
if test "$ESD_CONFIG" = "no" ; then
no_esd=yes
else
ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
esd_major_version=`$ESD_CONFIG $esd_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
esd_minor_version=`$ESD_CONFIG $esd_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_esdtest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $ESD_CFLAGS"
LIBS="$LIBS $ESD_LIBS"
dnl
dnl Now check if the installed ESD is sufficiently new. (Also sanity
dnl checks the results of esd-config to some extent
dnl
rm -f conf.esdtest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <esd.h>
char*
my_strdup (char *str)
{
char *new_str;
if (str)
{
new_str = malloc ((strlen (str) + 1) * sizeof(char));
strcpy (new_str, str);
}
else
new_str = NULL;
return new_str;
}
int main ()
{
int major, minor, micro;
char *tmp_version;
system ("touch conf.esdtest");
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = my_strdup("$min_esd_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_esd_version");
exit(1);
}
if (($esd_major_version > major) ||
(($esd_major_version == major) && ($esd_minor_version > minor)) ||
(($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
printf("*** best to upgrade to the required version.\n");
printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
printf("*** to point to the correct copy of esd-config, and remove the file\n");
printf("*** config.cache before re-running configure\n");
return 1;
}
}
],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_esd" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$ESD_CONFIG" = "no" ; then
echo "*** The esd-config script installed by ESD could not be found"
echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the ESD_CONFIG environment variable to the"
echo "*** full path to esd-config."
else
if test -f conf.esdtest ; then
:
else
echo "*** Could not run ESD test program, checking why..."
CFLAGS="$CFLAGS $ESD_CFLAGS"
LIBS="$LIBS $ESD_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include <esd.h>
], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding ESD or finding the wrong"
echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means ESD was incorrectly installed"
echo "*** or that you have moved ESD since it was installed. In the latter case, you"
echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
ESD_CFLAGS=""
ESD_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(ESD_CFLAGS)
AC_SUBST(ESD_LIBS)
rm -f conf.esdtest
])

View File

@@ -1,141 +0,0 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
PKG_NAME="GNOME Control Center"
(test -f $srcdir/configure.in \
&& test -d $srcdir/capplets \
&& test -d $srcdir/control-center) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level "\`$PKG_NAME\'" directory"
exit 1
}
ORIGDIR=`pwd`
cd $srcdir
PROJECT=control-center
TEST_TYPE=-f
DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $PROJECT."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have automake installed to compile $PROJECT."
echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
(grep "^AM_PROG_LIBTOOL" configure.in >/dev/null) && {
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed to compile $PROJECT."
echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
grep "^AM_GNU_GETTEXT" configure.in >/dev/null && {
grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
(gettext --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`gettext' installed to compile $PROJECT."
echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
case $CC in
*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
esac
for coin in `find . -name configure.in -print`
do
dr=`dirname $coin`
if test -f $dr/NO-AUTO-GEN; then
echo skipping $dr -- flagged as no auto-gen
else
echo processing $dr
macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
( cd $dr
aclocalinclude="$ACLOCAL_FLAGS"
for k in $macrodirs; do
if test -d $k; then
aclocalinclude="$aclocalinclude -I $k"
##else
## echo "**Warning**: No such directory \`$k'. Ignored."
fi
done
if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then
if grep "sed.*POTFILES" configure.in >/dev/null; then
: do nothing -- we still have an old unmodified configure.in
else
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
echo "no" | gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
fi
if grep "^AM_GNOME_GETTEXT" configure.in >/dev/null; then
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
echo "no" | gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
echo "Running libtoolize..."
libtoolize --force --copy
fi
echo "Running aclocal $aclocalinclude ..."
aclocal $aclocalinclude
if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
echo "Running autoheader..."
autoheader
fi
echo "Running automake --gnu $am_opt ..."
automake --add-missing --gnu $am_opt
echo "Running autoconf ..."
autoconf
)
fi
done
conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
cd "$ORIGDIR"
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile $PROJECT || exit 1
else
echo Skipping configure process.
fi

View File

@@ -1,2 +0,0 @@
Makefile.in
Makefile

View File

@@ -1,9 +0,0 @@
always_built_SUBDIRS = desktop-links mouse-properties \
screensaver-properties background-properties \
theme-switcher sound-properties bell-properties \
ui-properties url-properties gnome-edit-properties \
session-properties wm-properties keyboard-properties\
mime-type
SUBDIRS = $(always_built_SUBDIRS)

View File

@@ -1,4 +1,4 @@
INCLUDES = -I. -I$(srcdir) \
INCLUDES = -I. -I$(srcdir) -I$(top_srcdir) \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(top_srcdir)/libgnomevfs \
$(CAPPLET_INCLUDEDIR) \
@@ -14,6 +14,7 @@ nautilus_mime_type_capplet_SOURCES = \
nautilus-mime-type-capplet-dialogs.h \
nautilus-mime-type-capplet.c \
nautilus-mime-type-capplet-dialogs.c \
nautilus-mime-type-icon-entry.h \
nautilus-mime-type-icon-entry.c
nautilus_mime_type_capplet_LDADD = \

View File

@@ -1,26 +0,0 @@
INCLUDES = -I. -I$(srcdir) \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(srcdir)/../../control-center \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) $(GNOME_INCLUDEDIR)
bin_PROGRAMS = mime-type-capplet
mime_type_capplet_SOURCES = mime-type-capplet.c\
mime-data.h mime-data.c edit-window.c\
edit-window.h mime-info.c mime-info.h \
new-mime-window.h new-mime-window.c
mime_type_capplet_LDADD = ../../control-center/libcapplet.la \
$(GNOME_LIBS) $(ORBIT_LIBS) \
$(GNOMEUI_LIBS) $(INTLLIBS)
EXTRA_DIST = \
mime-type.desktop
sysdir = $(datadir)/control-center
sys_DATA = mime-type.desktop
install-data-local:
$(INSTALL_DATA) $(srcdir)/mime-type.desktop $(DESTDIR)$(datadir)/gnome/apps/Settings/mime-type.desktop

View File

@@ -1,573 +0,0 @@
#include "edit-window.h"
#include "mime-data.h"
#include "mime-info.h"
#include "capplet-widget.h"
extern GtkWidget *capplet;
extern GHashTable *user_mime_types;
typedef struct {
GtkWidget *window;
GtkWidget *icon_entry;
GtkWidget *mime_type;
/* GtkWidget *ext_tag_label; */
GtkWidget *regexp1_tag_label;
GtkWidget *regexp2_tag_label;
/* GtkWidget *ext_label; */
GtkWidget *regexp1_label;
GtkWidget *regexp2_label;
GtkWidget *open_entry;
GtkWidget *edit_entry;
GtkWidget *view_entry;
GtkWidget *ext_scroll;
GtkWidget *ext_clist;
GtkWidget *ext_entry;
GtkWidget *ext_add_button;
GtkWidget *ext_remove_button;
MimeInfo *mi;
MimeInfo *user_mi;
GList *tmp_ext[2];
} edit_window;
static edit_window *main_win = NULL;
static gboolean changing = TRUE;
static void
destruction_handler (GtkWidget *widget, gpointer data)
{
g_free (main_win);
main_win = NULL;
}
static void
entry_changed (GtkWidget *widget, gpointer data)
{
if (changing == FALSE)
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
TRUE);
}
static void
ext_clist_selected (GtkWidget *clist, gint row, gint column, gpointer data)
{
gboolean deletable;
deletable = GPOINTER_TO_INT (gtk_clist_get_row_data (GTK_CLIST (clist), row));
if (deletable)
gtk_widget_set_sensitive (main_win->ext_remove_button, TRUE);
else
gtk_widget_set_sensitive (main_win->ext_remove_button, FALSE);
}
static void
ext_clist_deselected (GtkWidget *clist, gint row, gint column, gpointer data)
{
if (g_list_length (GTK_CLIST (clist)->selection) == 0)
gtk_widget_set_sensitive (main_win->ext_remove_button, FALSE);
}
static void
ext_entry_changed (GtkWidget *entry, gpointer data)
{
gchar *text;
text = gtk_entry_get_text (GTK_ENTRY (entry));
gtk_widget_set_sensitive (main_win->ext_add_button, (strlen (text) >0));
}
static void
ext_add (GtkWidget *widget, gpointer data)
{
gchar *row[1];
gint rownumber;
row[0] = g_strdup (gtk_entry_get_text (GTK_ENTRY (main_win->ext_entry)));
rownumber = gtk_clist_append (GTK_CLIST (main_win->ext_clist), row);
gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist), rownumber,
GINT_TO_POINTER (TRUE));
gtk_entry_set_text (GTK_ENTRY (main_win->ext_entry), "");
main_win->tmp_ext[0] = g_list_prepend (main_win->tmp_ext[0], row[0]);
if (changing == FALSE)
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
TRUE);
}
static void
ext_remove (GtkWidget *widget, gpointer data)
{
gint row;
gchar *text;
gchar *store;
GList *tmp;
text = (gchar *)g_malloc (sizeof (gchar) * 1024);
gtk_clist_freeze (GTK_CLIST (main_win->ext_clist));
row = GPOINTER_TO_INT (GTK_CLIST (main_win->ext_clist)->selection->data);
gtk_clist_get_text (GTK_CLIST (main_win->ext_clist), row, 0, &text);
store = g_strdup (text);
gtk_clist_remove (GTK_CLIST (main_win->ext_clist), row);
gtk_clist_thaw (GTK_CLIST (main_win->ext_clist));
for (tmp = main_win->tmp_ext[0]; tmp; tmp = tmp->next) {
GList *found;
if (strcmp (tmp->data, store) == 0) {
found = tmp;
main_win->tmp_ext[0] = g_list_remove_link (main_win->tmp_ext[0], found);
g_list_free_1 (found);
break;
}
}
if (changing == FALSE)
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
TRUE);
}
static void
apply_entry_change (GtkWidget *entry, gchar *key, MimeInfo *mi)
{
const gchar *buf;
gchar *text;
/* buf is the value that existed before when we
* started the capplet */
buf = local_mime_get_value (mi->mime_type, key);
if (buf == NULL)
buf = gnome_mime_get_value (mi->mime_type, key);
text = gtk_entry_get_text (GTK_ENTRY (entry));
if (text && !*text)
text = NULL;
/* First we see if they've added something. */
if (buf == NULL && text)
set_mime_key_value (mi->mime_type, key, text);
else {
/* Has the value changed? */
if (text && strcmp (text, buf))
set_mime_key_value (mi->mime_type, key, text);
else
/* We _REALLY_ need a way to specify in
* user.keys not to use the system defaults.
* (ie. override the system default and
* query it).
* If we could then we'd set it here. */
;
}
}
static GList*
copy_mi_extensions (GList *orig)
{
GList *tmp;
GList *list = NULL;
for (tmp = orig; tmp; tmp = tmp->next) {
list = g_list_append (list, g_strdup (tmp->data));
}
return list;
}
static void
make_readable (MimeInfo *mi)
{
GList *list;
GString *extension;
extension = g_string_new ("");
for (list = ((MimeInfo *) mi)->user_ext[0]; list; list = list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
mi->ext_readable[0] = extension->str;
g_string_free (extension, FALSE);
extension = g_string_new ("");
for (list = ((MimeInfo *) mi)->user_ext[1]; list; list = list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
mi->ext_readable[1] = extension->str;
g_string_free (extension, FALSE);
}
static void
apply_changes (MimeInfo *mi)
{
GList *tmp;
int i;
apply_entry_change (gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (main_win->icon_entry)),
"icon-filename", mi);
apply_entry_change (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->open_entry)),
"open", mi);
apply_entry_change (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->view_entry)),
"view", mi);
apply_entry_change (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->edit_entry)),
"edit", mi);
if (!main_win->user_mi) {
add_to_key (mi->mime_type, "ext: tmp", user_mime_types, TRUE);
/* the tmp extension will be removed when we copy the tmp_ext
* stuff over the top of it.
*/
main_win->user_mi = g_hash_table_lookup (user_mime_types,
mi->mime_type);
}
for (i = 0; i < 2; i++) {
if (main_win->tmp_ext[i]) {
main_win->user_mi->user_ext[i] = copy_mi_extensions (main_win->tmp_ext[i]);
mi->user_ext[i] = copy_mi_extensions (main_win->tmp_ext[i]);
} else {
main_win->user_mi->user_ext[i] = NULL;
mi->user_ext[i] = NULL;
}
}
make_readable (main_win->user_mi);
if (! (main_win->user_mi->ext[0] || main_win->user_mi->ext[1] ||
main_win->user_mi->user_ext[0] || main_win->user_mi->ext[1]))
g_hash_table_remove (user_mime_types, mi->mime_type);
/* Free the 2 tmp lists */
for (i = 0; i < 2; i++) {
if (main_win->tmp_ext[i])
for (tmp = main_win->tmp_ext[i]; tmp; tmp = tmp->next)
g_free (tmp->data);
}
if (changing == FALSE)
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
TRUE);
}
static void
browse_callback (GtkWidget *widget, gpointer data)
{
}
static void
initialize_main_win ()
{
GtkWidget *align, *vbox, *hbox, *vbox2, *vbox3;
GtkWidget *frame, *table, *label;
GtkWidget *button;
GString *extension;
gchar *title[2] = {"Extensions"};
main_win = g_new (edit_window, 1);
main_win->window = gnome_dialog_new ("",
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
gtk_signal_connect (GTK_OBJECT (main_win->window),
"destroy",
destruction_handler,
NULL);
vbox = GNOME_DIALOG (main_win->window)->vbox;
/* icon box */
main_win->icon_entry = gnome_icon_entry_new ("mime_icon_entry", _("Select an icon..."));
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), main_win->icon_entry);
gtk_signal_connect (GTK_OBJECT (gnome_icon_entry_gtk_entry (GNOME_ICON_ENTRY (main_win->icon_entry))),
"changed",
entry_changed,
NULL);
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Mime Type: ")), FALSE, FALSE, 0);
main_win->mime_type = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), main_win->mime_type, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
/* extension/regexp */
vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
main_win->ext_clist = gtk_clist_new_with_titles (1, title);
gtk_clist_column_titles_passive (GTK_CLIST (main_win->ext_clist));
gtk_clist_set_auto_sort (GTK_CLIST (main_win->ext_clist), TRUE);
gtk_signal_connect (GTK_OBJECT (main_win->ext_clist),
"select-row",
GTK_SIGNAL_FUNC (ext_clist_selected),
NULL);
gtk_signal_connect (GTK_OBJECT (main_win->ext_clist),
"unselect-row",
GTK_SIGNAL_FUNC (ext_clist_deselected),
NULL);
main_win->ext_scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (main_win->ext_scroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (main_win->ext_scroll),
main_win->ext_clist);
vbox3 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
main_win->ext_add_button = gtk_button_new_with_label (_("Add"));
gtk_signal_connect (GTK_OBJECT (main_win->ext_add_button),
"clicked",
GTK_SIGNAL_FUNC (ext_add),
NULL);
gtk_box_pack_start (GTK_BOX (vbox3), main_win->ext_add_button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (main_win->ext_add_button, FALSE);
main_win->ext_remove_button = gtk_button_new_with_label (_("Remove"));
gtk_signal_connect (GTK_OBJECT (main_win->ext_remove_button),
"clicked",
GTK_SIGNAL_FUNC (ext_remove),
NULL);
gtk_widget_set_sensitive (main_win->ext_remove_button, FALSE);
gtk_box_pack_start (GTK_BOX (vbox3), main_win->ext_remove_button,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), main_win->ext_scroll, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), vbox3, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, TRUE, TRUE, 0);
main_win->ext_entry = gtk_entry_new ();
gtk_signal_connect (GTK_OBJECT (main_win->ext_entry),
"changed",
ext_entry_changed,
NULL);
gtk_signal_connect (GTK_OBJECT (main_win->ext_entry),
"activate",
ext_add,
NULL);
gtk_box_pack_start (GTK_BOX (vbox2), main_win->ext_entry, TRUE, TRUE, 0);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
main_win->regexp1_label = gtk_label_new ("");
main_win->regexp1_tag_label = gtk_label_new (_("First Regular Expression: "));
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp1_tag_label,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp1_label, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
main_win->regexp2_label = gtk_label_new ("");
main_win->regexp2_tag_label = gtk_label_new (_("Second Regular Expression: "));
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp2_tag_label,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), main_win->regexp2_label, FALSE, FALSE, 0);
/* Actions box */
frame = gtk_frame_new (_("Mime Type Actions"));
vbox2 = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
table = gtk_table_new (3, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
label = gtk_label_new (_("Example: emacs %f"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
label = gtk_label_new (_("Open"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 0, 1);
main_win->open_entry = gnome_file_entry_new ("MIME_CAPPLET_OPEN", _("Select a file..."));
gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->open_entry))),
"changed",
entry_changed,
NULL);
gtk_table_attach_defaults (GTK_TABLE (table),
main_win->open_entry,
1, 2, 0, 1);
label = gtk_label_new (_("View"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 1, 2);
main_win->view_entry = gnome_file_entry_new ("MIME_CAPPLET_VIEW", _("Select a file..."));
gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->view_entry))),
"changed",
entry_changed,
NULL);
gtk_table_attach_defaults (GTK_TABLE (table),
main_win->view_entry,
1, 2, 1, 2);
label = gtk_label_new (_("Edit"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (label), 2, 0);
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 2, 3);
main_win->edit_entry = gnome_file_entry_new ("MIME_CAPPLET_EDIT", _("Select a file..."));
gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (main_win->edit_entry))),
"changed",
entry_changed,
NULL);
gtk_table_attach_defaults (GTK_TABLE (table),
main_win->edit_entry,
1, 2, 2, 3);
}
static void
setup_entry (gchar *key, GtkWidget *g_entry, MimeInfo *mi)
{
const gchar *buf;
GtkWidget *entry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (g_entry));
buf = local_mime_get_value (mi->mime_type, key);
if (buf == NULL)
buf = gnome_mime_get_value (mi->mime_type, key);
if (buf)
gtk_entry_set_text (GTK_ENTRY (entry), buf);
else
gtk_entry_set_text (GTK_ENTRY (entry), "");
}
void
initialize_main_win_vals (void)
{
MimeInfo *mi;
gchar *title;
gboolean showext = FALSE;
if (main_win == NULL)
return;
mi = main_win->mi;
if (mi == NULL)
return;
/* now we fill in the fields with the mi stuff. */
changing = TRUE;
gtk_label_set_text (GTK_LABEL (main_win->mime_type), mi->mime_type);
gnome_icon_entry_set_icon (GNOME_ICON_ENTRY (main_win->icon_entry),
gnome_mime_get_value (mi->mime_type,
"icon-filename"));
gtk_widget_show_all (GNOME_DIALOG (main_win->window)->vbox);
/* we initialize everything */
title = g_strdup_printf (_("Set actions for %s"), mi->mime_type);
gtk_window_set_title (GTK_WINDOW (main_win->window), title);
g_free (title);
/* not sure why this is necessary */
gtk_clist_clear (GTK_CLIST (main_win->ext_clist));
if (mi->ext[0]) {
GList *tmp;
gchar *extension[1];
gint row;
for (tmp = mi->ext[0]; tmp; tmp = tmp->next) {
extension[0] = g_strdup (tmp->data);
row = gtk_clist_append (GTK_CLIST (main_win->ext_clist),
extension);
gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist),
row, GINT_TO_POINTER (FALSE));
}
showext = TRUE;
}
if (mi->ext[1]) {
GList *tmp;
gchar *extension[1];
gint row;
for (tmp = mi->ext[1]; tmp; tmp = tmp->next) {
extension[0] = g_strdup (tmp->data);
row = gtk_clist_append (GTK_CLIST (main_win->ext_clist),
extension);
gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist),
row, GINT_TO_POINTER (FALSE));
}
showext = TRUE;
}
if (main_win->tmp_ext[0]) {
GList *tmp;
gchar *extension[1];
gint row;
for (tmp = main_win->tmp_ext[0]; tmp; tmp = tmp->next) {
extension[0] = g_strdup (tmp->data);
row = gtk_clist_append (GTK_CLIST (main_win->ext_clist),
extension);
gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist),
row, GINT_TO_POINTER (TRUE));
}
showext = TRUE;
}
if (main_win->tmp_ext[1]) {
GList *tmp;
gchar *extension[1];
gint row;
for (tmp = main_win->tmp_ext[0]; tmp; tmp = tmp->next) {
extension[0] = g_strdup (tmp->data);
row = gtk_clist_append (GTK_CLIST (main_win->ext_clist),
extension);
gtk_clist_set_row_data (GTK_CLIST (main_win->ext_clist),
row, GINT_TO_POINTER (TRUE));
}
showext = TRUE;
}
if (!showext) {
gtk_widget_hide (main_win->ext_clist);
gtk_widget_hide (main_win->ext_entry);
gtk_widget_hide (main_win->ext_add_button);
gtk_widget_hide (main_win->ext_remove_button);
gtk_widget_hide (main_win->ext_scroll);
}
if (mi->regex_readable[0])
gtk_label_set_text (GTK_LABEL (main_win->regexp1_label),
mi->regex_readable[0]);
else {
gtk_widget_hide (main_win->regexp1_label);
gtk_widget_hide (main_win->regexp1_tag_label);
}
if (mi->regex_readable[1])
gtk_label_set_text (GTK_LABEL (main_win->regexp2_label),
mi->regex_readable[1]);
else {
gtk_widget_hide (main_win->regexp2_label);
gtk_widget_hide (main_win->regexp2_tag_label);
}
/* initialize the entries */
setup_entry ("open", main_win->open_entry, mi);
setup_entry ("view", main_win->view_entry, mi);
setup_entry ("edit", main_win->edit_entry, mi);
changing = FALSE;
}
void
launch_edit_window (MimeInfo *mi)
{
gint size;
if (main_win == NULL)
initialize_main_win ();
main_win->mi = mi;
main_win->user_mi = g_hash_table_lookup (user_mime_types, mi->mime_type);
main_win->tmp_ext[0] = NULL;
main_win->tmp_ext[1] = NULL;
if (main_win->user_mi) {
if (main_win->user_mi->user_ext[0])
main_win->tmp_ext[0] = copy_mi_extensions (main_win->user_mi->user_ext[0]);
if (main_win->user_mi->user_ext[1])
main_win->tmp_ext[1] = copy_mi_extensions (main_win->user_mi->user_ext[1]);
}
initialize_main_win_vals ();
switch(gnome_dialog_run (GNOME_DIALOG (main_win->window))) {
case 0:
apply_changes (mi);
case 1:
main_win->mi = NULL;
gtk_widget_hide (main_win->window);
break;
}
}
void
hide_edit_window (void)
{
if (main_win && main_win->mi && main_win->window)
gtk_widget_hide (main_win->window);
}
void
show_edit_window (void)
{
if (main_win && main_win->mi && main_win->window)
gtk_widget_show (main_win->window);
}

View File

@@ -1,15 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#include "mime-data.h"
#ifndef _EDIT_WINDOW_H_
#define _EDIT_WINDOW_H_
void launch_edit_window (MimeInfo *mi);
void initialize_main_win_vals (void);
void hide_edit_window (void);
void show_edit_window (void);
#endif

View File

@@ -1,656 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#include <config.h>
#include "capplet-widget.h"
#include "gnome.h"
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <regex.h>
#include <ctype.h>
#include "edit-window.h"
#include "mime-data.h"
#include "mime-info.h"
#include "new-mime-window.h"
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
/* Prototypes */
static void mime_fill_from_file (const char *filename, gboolean init_user);
static void mime_load_from_dir (const char *mime_info_dir, gboolean system_dir);
void add_to_key (char *mime_type, char *def, GHashTable *table, gboolean init_user);
static char *get_priority (char *def, int *priority);
/* Global variables */
static char *current_lang;
static GHashTable *mime_types = NULL;
static GHashTable *initial_user_mime_types = NULL;
GHashTable *user_mime_types = NULL;
static GtkWidget *clist = NULL;
extern GtkWidget *delete_button;
extern GtkWidget *capplet;
/* Initialization functions */
static void
run_error (gchar *message)
{
GtkWidget *error_box;
error_box = gnome_message_box_new (
message,
GNOME_MESSAGE_BOX_ERROR,
GNOME_STOCK_BUTTON_OK,
NULL);
gnome_dialog_run_and_close (GNOME_DIALOG (error_box));
}
static char *
get_priority (char *def, int *priority)
{
*priority = 0;
if (*def == ','){
def++;
if (*def == '1'){
*priority = 0;
def++;
} else if (*def == '2'){
*priority = 1;
def++;
}
}
while (*def && *def == ':')
def++;
return def;
}
static void
free_mime_info (MimeInfo *mi)
{
}
void
add_to_key (char *mime_type, char *def, GHashTable *table, gboolean init_user)
{
int priority = 1;
char *s, *p, *ext;
int used;
MimeInfo *info;
info = g_hash_table_lookup (table, (const void *) mime_type);
if (info == NULL) {
info = g_malloc (sizeof (MimeInfo));
info->mime_type = g_strdup (mime_type);
info->regex[0] = NULL;
info->regex[1] = NULL;
info->ext[0] = NULL;
info->ext[1] = NULL;
info->user_ext[0] = NULL;
info->user_ext[1] = NULL;
info->regex_readable[0] = NULL;
info->regex_readable[1] = NULL;
info->ext_readable[0] = NULL;
info->ext_readable[1] = NULL;
info->keys = gnome_mime_get_keys (mime_type);
g_hash_table_insert (table, info->mime_type, info);
}
if (strncmp (def, "ext", 3) == 0){
char *tokp;
def += 3;
def = get_priority (def, &priority);
s = p = g_strdup (def);
used = 0;
while ((ext = strtok_r (s, " \t\n\r,", &tokp)) != NULL){
/* FIXME: We really need to check for duplicates before entering this. */
if (!init_user) {
info->ext[priority] = g_list_prepend (info->ext[priority], ext);
} else {
info->user_ext[priority] = g_list_prepend (info->user_ext[priority], ext);
}
used = 1;
s = NULL;
}
if (!used)
g_free (p);
}
if (strncmp (def, "regex", 5) == 0){
regex_t *regex;
regex = g_new (regex_t, 1);
def += 5;
def = get_priority (def, &priority);
while (*def && isspace (*def))
def++;
if (!*def)
return;
if (regcomp (regex, def, REG_EXTENDED | REG_NOSUB))
g_free (regex);
else {
info->regex[priority] = regex;
g_free (info->regex_readable[priority]);
info->regex_readable[priority] = g_strdup (def);
}
}
}
static void
mime_fill_from_file (const char *filename, gboolean init_user)
{
FILE *f;
char buf [1024];
char *current_key;
gboolean used;
g_assert (filename != NULL);
f = fopen (filename, "r");
if (!f)
return;
current_key = NULL;
used = FALSE;
while (fgets (buf, sizeof (buf), f)){
char *p;
if (buf [0] == '#')
continue;
/* Trim trailing spaces */
for (p = buf + strlen (buf) - 1; p >= buf; p--){
if (isspace (*p) || *p == '\n')
*p = 0;
else
break;
}
if (!buf [0])
continue;
if (buf [0] == '\t' || buf [0] == ' '){
if (current_key){
char *p = buf;
while (*p && isspace (*p))
p++;
if (*p == 0)
continue;
add_to_key (current_key, p, mime_types, init_user);
if (init_user) {
add_to_key (current_key, p,
initial_user_mime_types,
TRUE);
add_to_key (current_key, p,
user_mime_types, TRUE);
}
used = TRUE;
}
} else {
if (!used && current_key)
g_free (current_key);
current_key = g_strdup (buf);
if (current_key [strlen (current_key)-1] == ':')
current_key [strlen (current_key)-1] = 0;
used = FALSE;
}
}
fclose (f);
}
static void
mime_load_from_dir (const char *mime_info_dir, gboolean system_dir)
{
DIR *dir;
struct dirent *dent;
const int extlen = sizeof (".mime") - 1;
char *filename;
dir = opendir (mime_info_dir);
if (!dir)
return;
if (system_dir) {
filename = g_concat_dir_and_file (mime_info_dir, "gnome.mime");
mime_fill_from_file (filename, FALSE);
g_free (filename);
}
while ((dent = readdir (dir)) != NULL){
int len = strlen (dent->d_name);
if (len <= extlen)
continue;
if (strcmp (dent->d_name + len - extlen, ".mime"))
continue;
if (system_dir && !strcmp (dent->d_name, "gnome.mime"))
continue;
if (!system_dir && !strcmp (dent->d_name, "user.mime"))
continue;
filename = g_concat_dir_and_file (mime_info_dir, dent->d_name);
mime_fill_from_file (filename, FALSE);
g_free (filename);
}
if (!system_dir) {
filename = g_concat_dir_and_file (mime_info_dir, "user.mime");
mime_fill_from_file (filename, TRUE);
g_free (filename);
}
closedir (dir);
}
static int
add_mime_vals_to_clist (gchar *mime_type, gpointer mi, gpointer cl)
{
/* we also finalize the MimeInfo structure here, now that we're done
* loading it */
static gchar *text[2];
GList *list;
GString *extension;
gint row;
extension = g_string_new ("");
for (list = ((MimeInfo *) mi)->ext[0];list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
if (strcmp (extension->str, "") != 0 && ((MimeInfo *)mi)->user_ext[0])
g_string_append (extension, ", ");
for (list = ((MimeInfo *) mi)->user_ext[0]; list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
((MimeInfo *) mi)->ext_readable[0] = extension->str;
g_string_free (extension, FALSE);
extension = g_string_new ("");
for (list = ((MimeInfo *) mi)->ext[1];list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next)
g_string_append (extension, ", ");
}
if (strcmp (extension->str, "") != 0 && ((MimeInfo *)mi)->user_ext[1])
g_string_append (extension, ", ");
for (list = ((MimeInfo *) mi)->user_ext[1]; list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
((MimeInfo *) mi)->ext_readable[1] = extension->str;
g_string_free (extension, FALSE);
if (((MimeInfo *) mi)->ext[0] || ((MimeInfo *) mi)->user_ext[0]) {
extension = g_string_new ((((MimeInfo *) mi)->ext_readable[0]));
if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1]) {
g_string_append (extension, ", ");
g_string_append (extension, (((MimeInfo *) mi)->ext_readable[1]));
}
} else if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1])
extension = g_string_new ((((MimeInfo *) mi)->ext_readable[1]));
else
extension = g_string_new ("");
text[0] = ((MimeInfo *) mi)->mime_type;
text[1] = extension->str;
row = gtk_clist_insert (GTK_CLIST (cl), 1, text);
gtk_clist_set_row_data (GTK_CLIST (cl), row, mi);
g_string_free (extension, TRUE);
return row;
}
static void
selected_row_callback (GtkWidget *widget, gint row, gint column, GdkEvent *event, gpointer data)
{
MimeInfo *mi;
if (column < 0)
return;
mi = (MimeInfo *) gtk_clist_get_row_data (GTK_CLIST (widget),row);
if (event && event->type == GDK_2BUTTON_PRESS)
launch_edit_window (mi);
if (g_hash_table_lookup (user_mime_types, mi->mime_type)) {
gtk_widget_set_sensitive (delete_button, TRUE);
} else
gtk_widget_set_sensitive (delete_button, FALSE);
}
/* public functions */
void
delete_clicked (GtkWidget *widget, gpointer data)
{
MimeInfo *mi;
gint row = 0;
if (GTK_CLIST (clist)->selection)
row = GPOINTER_TO_INT ((GTK_CLIST (clist)->selection)->data);
else
return;
mi = (MimeInfo *) gtk_clist_get_row_data (GTK_CLIST (clist), row);
gtk_clist_remove (GTK_CLIST (clist), row);
g_hash_table_remove (user_mime_types, mi->mime_type);
remove_mime_info (mi->mime_type);
free_mime_info (mi);
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
TRUE);
}
void
edit_clicked (GtkWidget *widget, gpointer data)
{
MimeInfo *mi;
gint row = 0;
if (GTK_CLIST (clist)->selection)
row = GPOINTER_TO_INT ((GTK_CLIST (clist)->selection)->data);
else
return;
mi = (MimeInfo *) gtk_clist_get_row_data (GTK_CLIST (clist), row);
if (mi)
launch_edit_window (mi);
gtk_clist_remove (GTK_CLIST (clist), row);
row = add_mime_vals_to_clist (mi->mime_type, mi, clist);
gtk_clist_select_row (GTK_CLIST (clist), row, 0);
}
void
add_clicked (GtkWidget *widget, gpointer data)
{
launch_new_mime_window ();
}
GtkWidget *
get_mime_clist (void)
{
GtkWidget *retval;
gchar *titles[2];
titles[0] = _("Mime Type");
titles[1] = _("Extension");
retval = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (retval),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
clist = gtk_clist_new_with_titles (2, titles);
gtk_signal_connect (GTK_OBJECT (clist),
"select_row",
GTK_SIGNAL_FUNC (selected_row_callback),
NULL);
gtk_clist_set_selection_mode (GTK_CLIST (clist), GTK_SELECTION_BROWSE);
gtk_clist_set_auto_sort (GTK_CLIST (clist), TRUE);
if (clist)
g_hash_table_foreach (mime_types, (GHFunc) add_mime_vals_to_clist, clist);
gtk_clist_columns_autosize (GTK_CLIST (clist));
gtk_clist_select_row (GTK_CLIST (clist), 0, 0);
gtk_container_add (GTK_CONTAINER (retval), clist);
return retval;
}
static void
finalize_mime_type_foreach (gpointer mime_type, gpointer info, gpointer data)
{
MimeInfo *mi = (MimeInfo *)info;
GList *list;
GString *extension;
extension = g_string_new ("");
for (list = ((MimeInfo *) mi)->ext[0];list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
if (strcmp (extension->str, "") != 0 && mi->user_ext[0])
g_string_append (extension, ", ");
for (list = ((MimeInfo *) mi)->user_ext[0]; list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
((MimeInfo *) mi)->ext_readable[0] = extension->str;
g_string_free (extension, FALSE);
extension = g_string_new ("");
for (list = ((MimeInfo *) mi)->ext[1];list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next)
g_string_append (extension, ", ");
}
if (strcmp (extension->str, "") != 0 && mi->user_ext[1])
g_string_append (extension, ", ");
for (list = ((MimeInfo *) mi)->user_ext[1]; list; list=list->next) {
g_string_append (extension, (gchar *) list->data);
if (list->next != NULL)
g_string_append (extension, ", ");
}
((MimeInfo *) mi)->ext_readable[1] = extension->str;
g_string_free (extension, FALSE);
if (((MimeInfo *) mi)->ext[0] || ((MimeInfo *) mi)->user_ext[0]) {
extension = g_string_new ((((MimeInfo *) mi)->ext_readable[0]));
if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1]) {
g_string_append (extension, ", ");
g_string_append (extension, (((MimeInfo *) mi)->ext_readable[1]));
}
} else if (((MimeInfo *) mi)->ext[1] || ((MimeInfo *) mi)->user_ext[1])
extension = g_string_new ((((MimeInfo *) mi)->ext_readable[1]));
else
extension = g_string_new ("");
g_string_free (extension, TRUE);
}
static void
finalize_user_mime ()
{
g_hash_table_foreach (user_mime_types, finalize_mime_type_foreach, NULL);
g_hash_table_foreach (initial_user_mime_types, finalize_mime_type_foreach, NULL);
}
void
init_mime_type (void)
{
char *mime_info_dir;
mime_types = g_hash_table_new (g_str_hash, g_str_equal);
initial_user_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
user_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
mime_info_dir = gnome_unconditional_datadir_file ("mime-info");
mime_load_from_dir (mime_info_dir, TRUE);
g_free (mime_info_dir);
mime_info_dir = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info");
mime_load_from_dir (mime_info_dir, FALSE);
g_free (mime_info_dir);
finalize_user_mime ();
init_mime_info ();
}
void
add_new_mime_type (gchar *mime_type, gchar *raw_ext, gchar *regexp1, gchar *regexp2)
{
gchar *temp;
MimeInfo *mi = NULL;
gint row;
gchar *ext = NULL;
gchar *ptr, *ptr2;
/* first we make sure that the information is good */
if (mime_type == NULL || *mime_type == '\000') {
run_error (_("You must enter a mime-type"));
return;
} else if ((raw_ext == NULL || *raw_ext == '\000') &&
(regexp1 == NULL || *regexp1 == '\000') &&
(regexp2 == NULL || *regexp2 == '\000')){
run_error (_("You must add either a regular-expression or\na file-name extension"));
return;
}
if (strchr (mime_type, '/') == NULL) {
run_error (_("Please put your mime-type in the format:\nCATEGORY/TYPE\n\nFor Example:\nimage/png"));
return;
}
if (g_hash_table_lookup (user_mime_types, mime_type) ||
g_hash_table_lookup (mime_types, mime_type)) {
run_error (_("This mime-type already exists"));
return;
}
if (raw_ext || *raw_ext) {
ptr2 = ext = g_malloc (sizeof (raw_ext));
for (ptr = raw_ext;*ptr; ptr++) {
if (*ptr != '.' && *ptr != ',') {
*ptr2 = *ptr;
ptr2 += 1;
}
}
*ptr2 = '\000';
}
/* passed check, now we add it. */
if (ext) {
temp = g_strconcat ("ext: ", ext, NULL);
add_to_key (mime_type, temp, user_mime_types, TRUE);
mi = (MimeInfo *) g_hash_table_lookup (user_mime_types, mime_type);
g_free (temp);
}
if (regexp1) {
temp = g_strconcat ("regex: ", regexp1, NULL);
add_to_key (mime_type, temp, user_mime_types, TRUE);
g_free (temp);
}
if (regexp2) {
temp = g_strconcat ("regex,2: ", regexp2, NULL);
add_to_key (mime_type, temp, user_mime_types, TRUE);
g_free (temp);
}
/* Finally add it to the clist */
if (mi) {
row = add_mime_vals_to_clist (mime_type, mi, clist);
gtk_clist_select_row (GTK_CLIST (clist), row, 0);
gtk_clist_moveto (GTK_CLIST (clist), row, 0, 0.5, 0.0);
}
g_free (ext);
}
static void
write_mime_foreach (gpointer mime_type, gpointer info, gpointer data)
{
gchar *buf;
MimeInfo *mi = (MimeInfo *) info;
fwrite ((char *) mi->mime_type, 1, strlen ((char *) mi->mime_type), (FILE *) data);
fwrite ("\n", 1, 1, (FILE *) data);
if (mi->ext_readable[0]) {
fwrite ("\text: ", 1, strlen ("\text: "), (FILE *) data);
fwrite (mi->ext_readable[0], 1,
strlen (mi->ext_readable[0]),
(FILE *) data);
fwrite ("\n", 1, 1, (FILE *) data);
}
if (mi->regex_readable[0]) {
fwrite ("\tregex: ", 1, strlen ("\tregex: "), (FILE *) data);
fwrite (mi->regex_readable[0], 1,
strlen (mi->regex_readable[0]),
(FILE *) data);
fwrite ("\n", 1, 1, (FILE *) data);
}
if (mi->regex_readable[1]) {
fwrite ("\tregex,2: ", 1, strlen ("\tregex,2: "), (FILE *) data);
fwrite (mi->regex_readable[1], 1,
strlen (mi->regex_readable[1]),
(FILE *) data);
fwrite ("\n", 1, 1, (FILE *) data);
}
fwrite ("\n", 1, 1, (FILE *) data);
}
static void
write_mime (GHashTable *hash)
{
struct stat s;
gchar *dirname, *filename;
FILE *file;
GtkWidget *error_box;
dirname = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info");
if ((stat (dirname, &s) < 0) || !(S_ISDIR (s.st_mode))){
if (errno == ENOENT) {
if (mkdir (dirname, S_IRWXU) < 0) {
run_error (_("We are unable to create the directory\n"
"~/.gnome/mime-info\n\n"
"We will not be able to save the state."));
return;
}
} else {
run_error (_("We are unable to access the directory\n"
"~/.gnome/mime-info\n\n"
"We will not be able to save the state."));
return;
}
}
filename = g_concat_dir_and_file (dirname, "user.mime");
remove (filename);
file = fopen (filename, "w");
if (file == NULL) {
run_error (_("Cannot create the file\n~/.gnome/mime-info/user.mime\n\n"
"We will not be able to save the state"));
return;
}
g_hash_table_foreach (hash, write_mime_foreach, file);
fclose (file);
}
void
write_user_mime (void)
{
write_mime (user_mime_types);
}
void
write_initial_mime (void)
{
write_mime (initial_user_mime_types);
}
void
reread_list ()
{
gtk_clist_freeze (GTK_CLIST (clist));
gtk_clist_clear (GTK_CLIST (clist));
g_hash_table_foreach (mime_types, (GHFunc) add_mime_vals_to_clist, clist);
gtk_clist_thaw (GTK_CLIST (clist));
}
static void
clean_mime_type (gpointer mime_type, gpointer mime_info, gpointer data)
{
/* we should write this )-: */
}
void
discard_mime_info ()
{
gchar *filename;
g_hash_table_foreach (user_mime_types, clean_mime_type, NULL);
g_hash_table_destroy (user_mime_types);
g_hash_table_foreach (initial_user_mime_types, clean_mime_type, NULL);
g_hash_table_destroy (initial_user_mime_types);
user_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
initial_user_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
filename = g_concat_dir_and_file (gnome_util_user_home (), "/.gnome/mime-info/user.keys");
mime_fill_from_file (filename, TRUE);
finalize_user_mime ();
reread_list ();
g_free (filename);
}

View File

@@ -1,34 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#ifndef _MIME_DATA_H_
#define _MIME_DATA_H_
#include "gnome.h"
#include <regex.h>
/* Typedefs */
typedef struct {
char *mime_type;
regex_t *regex[2];
GList *ext[2];
GList *user_ext[2];
char *ext_readable[2];
char *regex_readable[2];
char *file_name;
GList *keys;
} MimeInfo;
extern GHashTable *user_mime_types;
extern void add_to_key (char *mime_type, char *def, GHashTable *table, gboolean init_user);
GtkWidget *get_mime_clist (void);
void init_mime_type (void);
void delete_clicked (GtkWidget *widget, gpointer data);
void add_clicked (GtkWidget *widget, gpointer data);
void edit_clicked (GtkWidget *widget, gpointer data);
void add_new_mime_type (gchar *mime_type, gchar *ext, gchar *regexp1, gchar *regexp2);
void write_user_mime (void);
void write_initial_mime (void);
void reread_list (void);
void discard_mime_info (void);
#endif

View File

@@ -1,488 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#include <config.h>
#include "capplet-widget.h"
#include "gnome.h"
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <regex.h>
#include <ctype.h>
#include "mime-info.h"
#include "mime-data.h"
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#if !defined getc_unlocked && !defined HAVE_GETC_UNLOCKED
# define getc_unlocked(fp) getc (fp)
#endif
typedef struct {
char *mime_type;
GHashTable *keys;
} GnomeMimeContext;
typedef enum {
STATE_NONE,
STATE_LANG,
STATE_LOOKING_FOR_KEY,
STATE_ON_MIME_TYPE,
STATE_ON_KEY,
STATE_ON_VALUE
} ParserState;
static char *current_lang = NULL;
/*
* A hash table containing all of the Mime records for specific
* mime types (full description, like image/png)
*/
static GHashTable *specific_types;
static GHashTable *initial_specific_types;
/*
* A hash table containing all of the Mime records for non-specific
* mime types (like image/\*)
*/
static GHashTable *generic_types;
static GHashTable *initial_generic_types;
#define SWITCH_TO_MIME_TYPE() {
static GnomeMimeContext *
context_new (GString *str, gboolean is_default_context)
{
GnomeMimeContext *context;
GHashTable *table;
char *mime_type, *p;
mime_type = g_strdup (str->str);
if (is_default_context) {
if ((p = strstr (mime_type, "/*")) == NULL){
table = initial_specific_types;
} else {
*(p+1) = 0;
table = initial_generic_types;
}
} else {
if ((p = strstr (mime_type, "/*")) == NULL){
table = specific_types;
} else {
*(p+1) = 0;
table = generic_types;
}
}
context = g_hash_table_lookup (table, mime_type);
if (context)
return context;
context = g_new (GnomeMimeContext, 1);
context->mime_type = mime_type;
context->keys = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (table, context->mime_type, context);
return context;
}
static gboolean
release_key_and_value (gpointer key, gpointer value, gpointer user_data)
{
g_free (key);
g_free (value);
return TRUE;
}
static gboolean
remove_this_key (gpointer key, gpointer value, gpointer user_data)
{
if (strcmp ((gchar *)key, (gchar *)user_data) == 0){
g_free (key);
g_free (value);
return TRUE;
}
return FALSE;
}
static void
context_add_key (GnomeMimeContext *context, char *key, char *value)
{
char *v;
v = g_hash_table_lookup (context->keys, key);
if (v)
g_hash_table_foreach_remove (context->keys, remove_this_key, key);
g_hash_table_insert (context->keys, g_strdup (key), g_strdup (value));
}
static void
context_destroy (GnomeMimeContext *context)
{
/*
* Remove the context from our hash tables, we dont know
* where it is: so just remove it from both (it can
* only be in one).
*/
if (context->mime_type) {
g_hash_table_remove (specific_types, context->mime_type);
g_hash_table_remove (generic_types, context->mime_type);
}
/*
* Destroy it
*/
if (context->keys) {
g_hash_table_foreach_remove (context->keys, release_key_and_value, NULL);
g_hash_table_destroy (context->keys);
}
g_free (context->mime_type);
g_free (context);
}
static void
load_mime_type_info_from (char *filename)
{
FILE *mime_file;
gboolean in_comment, context_used;
GString *line;
int column, c;
ParserState state;
GnomeMimeContext *context, *default_context;
char *key;
mime_file = fopen (filename, "r");
if (mime_file == NULL)
return;
in_comment = FALSE;
context_used = FALSE;
column = 0;
context = NULL;
default_context = NULL;
key = NULL;
line = g_string_sized_new (120);
state = STATE_NONE;
while ((c = getc_unlocked (mime_file)) != EOF){
column++;
if (c == '\r')
continue;
if (c == '#' && column == 0){
in_comment = TRUE;
continue;
}
if (c == '\n'){
in_comment = FALSE;
column = 0;
if (state == STATE_ON_MIME_TYPE){
context = context_new (line, FALSE);
default_context = context_new (line, TRUE);
context_used = FALSE;
g_string_assign (line, "");
state = STATE_LOOKING_FOR_KEY;
continue;
}
if (state == STATE_ON_VALUE){
context_used = TRUE;
context_add_key (context, key, line->str);
context_add_key (default_context, key, line->str);
g_string_assign (line, "");
g_free (key);
key = NULL;
state = STATE_LOOKING_FOR_KEY;
continue;
}
continue;
}
if (in_comment)
continue;
switch (state){
case STATE_NONE:
if (c != ' ' && c != '\t')
state = STATE_ON_MIME_TYPE;
else
break;
/* fall down */
case STATE_ON_MIME_TYPE:
if (c == ':'){
in_comment = TRUE;
break;
}
g_string_append_c (line, c);
break;
case STATE_LOOKING_FOR_KEY:
if (c == '\t' || c == ' ')
break;
if (c == '['){
state = STATE_LANG;
break;
}
if (column == 1){
state = STATE_ON_MIME_TYPE;
g_string_append_c (line, c);
break;
}
state = STATE_ON_KEY;
/* falldown */
case STATE_ON_KEY:
if (c == '\\'){
c = getc (mime_file);
if (c == EOF)
break;
}
if (c == '='){
key = g_strdup (line->str);
g_string_assign (line, "");
state = STATE_ON_VALUE;
break;
}
g_string_append_c (line, c);
break;
case STATE_ON_VALUE:
g_string_append_c (line, c);
break;
case STATE_LANG:
if (c == ']'){
state = STATE_ON_KEY;
if (current_lang && line->str [0]){
if (strcmp (current_lang, line->str) != 0){
in_comment = TRUE;
state = STATE_LOOKING_FOR_KEY;
}
} else {
in_comment = TRUE;
state = STATE_LOOKING_FOR_KEY;
}
g_string_assign (line, "");
break;
}
g_string_append_c (line, c);
break;
}
}
if (context){
if (key && line->str [0]) {
context_add_key (context, key, line->str);
context_add_key (default_context, key, line->str);
} else
if (!context_used) {
context_destroy (context);
context_destroy (default_context);
}
}
g_string_free (line, TRUE);
if (key)
g_free (key);
fclose (mime_file);
}
void
set_mime_key_value (gchar *mime_type, gchar *key, gchar *value)
{
GnomeMimeContext *context;
/* Assume no generic context's for now. */
context = g_hash_table_lookup (specific_types, mime_type);
if (context == NULL) {
GString *str = g_string_new (mime_type);
context = context_new (str, FALSE);
g_string_free (str, TRUE);
}
context_add_key (context, key, value);
}
void
init_mime_info (void)
{
gchar *filename;
current_lang = getenv ("LANG");
specific_types = g_hash_table_new (g_str_hash, g_str_equal);
generic_types = g_hash_table_new (g_str_hash, g_str_equal);
initial_specific_types = g_hash_table_new (g_str_hash, g_str_equal);
initial_generic_types = g_hash_table_new (g_str_hash, g_str_equal);
filename = g_concat_dir_and_file (gnome_util_user_home (), "/.gnome/mime-info/user.keys");
load_mime_type_info_from (filename);
g_free (filename);
}
const char *
local_mime_get_value (const char *mime_type, char *key)
{
char *value, *generic_type, *p;
GnomeMimeContext *context;
g_return_val_if_fail (mime_type != NULL, NULL);
g_return_val_if_fail (key != NULL, NULL);
context = g_hash_table_lookup (specific_types, mime_type);
if (context){
value = g_hash_table_lookup (context->keys, key);
if (value)
return value;
}
generic_type = g_strdup (mime_type);
p = strchr (generic_type, '/');
if (p)
*(p+1) = 0;
context = g_hash_table_lookup (generic_types, generic_type);
g_free (generic_type);
if (context){
value = g_hash_table_lookup (context->keys, key);
if (value)
return value;
}
return NULL;
}
static void
clean_mime_foreach (gpointer mime_type, gpointer gmc, gpointer data)
{
context_destroy ((GnomeMimeContext *) gmc);
}
static void
write_mime_keys_foreach (gpointer key_name, gpointer value, gpointer data)
{
gchar *buf;
if (current_lang && strcmp (current_lang, "C"))
buf = g_strconcat ("\t[",
current_lang,
"]",
(gchar *) key_name,
"=",
(gchar *) value,
"\n", NULL);
else
buf = g_strconcat ("\t",
(gchar *) key_name,
"=",
(gchar *) value,
"\n", NULL);
fwrite (buf, 1, strlen (buf), (FILE *) data);
g_free (buf);
}
static void
write_mime_foreach (gpointer mime_type, gpointer gmc, gpointer data)
{
gchar *buf;
GnomeMimeContext *context = (GnomeMimeContext *) gmc;
buf = g_strconcat ((gchar *) mime_type, ":\n", NULL);
fwrite (buf, 1, strlen (buf), (FILE *) data);
g_free (buf);
g_hash_table_foreach (context->keys, write_mime_keys_foreach, data);
fwrite ("\n", 1, strlen ("\n"), (FILE *) data);
}
static void
run_error (gchar *message)
{
GtkWidget *error_box;
error_box = gnome_message_box_new (
message,
GNOME_MESSAGE_BOX_ERROR,
GNOME_STOCK_BUTTON_OK,
NULL);
gnome_dialog_run_and_close (GNOME_DIALOG (error_box));
}
static void
write_keys (GHashTable *spec_hash, GHashTable *generic_hash)
{
struct stat s;
gchar *dirname, *filename;
FILE *file;
GtkWidget *error_box;
dirname = g_concat_dir_and_file (gnome_util_user_home (), ".gnome/mime-info");
if ((stat (dirname, &s) < 0) || !(S_ISDIR (s.st_mode))){
if (errno == ENOENT) {
if (mkdir (dirname, S_IRWXU) < 0) {
run_error (_("We are unable to create the directory\n"
"~/.gnome/mime-info.\n\n"
"We will not be able to save the state."));
return;
}
} else {
run_error (_("We are unable to access the directory\n"
"~/.gnome/mime-info.\n\n"
"We will not be able to save the state."));
return;
}
}
filename = g_concat_dir_and_file (dirname, "user.keys");
remove (filename);
file = fopen (filename, "w");
if (file == NULL) {
run_error (_("Cannot create the file\n~/.gnome/mime-info/user.keys.\n\n"
"We will not be able to save the state"));
return;
}
g_hash_table_foreach (spec_hash, write_mime_foreach, file);
g_hash_table_foreach (generic_hash, write_mime_foreach, file);
fclose (file);
}
void
write_initial_keys (void)
{
write_keys (initial_generic_types, initial_specific_types);
}
void
write_user_keys (void)
{
write_keys (generic_types, specific_types);
}
static void
print_mime_foreach (gpointer mime_info, gpointer mi, gpointer data)
{
g_print ("mime_info:%s:\n", (char *)mime_info);
g_print ("\t:%s:\n", ((MimeInfo *)mi)->mime_type);
}
void
discard_key_info (void)
{
gchar *filename;
current_lang = getenv ("LANG");
g_hash_table_foreach (generic_types, clean_mime_foreach, NULL);
/* g_hash_table_foreach (specific_types, print_mime_foreach, NULL); */
g_hash_table_foreach (specific_types, clean_mime_foreach, NULL);
g_hash_table_destroy (generic_types);
g_hash_table_destroy (specific_types);
specific_types = g_hash_table_new (g_str_hash, g_str_equal);
generic_types = g_hash_table_new (g_str_hash, g_str_equal);
filename = g_concat_dir_and_file (gnome_util_user_home (), "/.gnome/mime-info/user.keys");
load_mime_type_info_from (filename);
reread_list ();
g_free (filename);
}
void
remove_mime_info (gchar *mime_type)
{
g_hash_table_remove (generic_types, mime_type);
g_hash_table_remove (specific_types, mime_type);
}

View File

@@ -1,17 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#ifndef _MIME_INFO_H_
#define _MIME_INFO_H_
#include "gnome.h"
#include <regex.h>
/* Typedefs */
void init_mime_info (void);
void discard_key_info (void);
void set_mime_key_value (gchar *mime_type, gchar *key, gchar *value);
const char * local_mime_get_value (const char *mime_type, char *key);
void write_user_keys (void);
void write_initial_keys (void);
void remove_mime_info (gchar *mime_type);
#endif

View File

@@ -1,138 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#include <config.h>
#include "capplet-widget.h"
#include "gnome.h"
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <regex.h>
#include <ctype.h>
#include "mime-data.h"
#include "mime-info.h"
#include "edit-window.h"
/* Prototypes */
static void try_callback ();
static void revert_callback ();
static void ok_callback ();
static void cancel_callback ();
static void help_callback ();
GtkWidget *capplet = NULL;
GtkWidget *delete_button = NULL;
static GtkWidget *
left_aligned_button (gchar *label)
{
GtkWidget *button = gtk_button_new_with_label (label);
gtk_misc_set_alignment (GTK_MISC (GTK_BIN (button)->child),
0.0, 0.5);
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child),
GNOME_PAD_SMALL, 0);
return button;
}
static void
try_callback ()
{
write_user_keys ();
write_user_mime ();
}
static void
revert_callback ()
{
write_initial_keys ();
write_initial_mime ();
discard_key_info ();
discard_mime_info ();
initialize_main_win_vals ();
}
static void
ok_callback ()
{
write_user_keys ();
write_user_mime ();
}
static void
cancel_callback ()
{
write_initial_keys ();
write_initial_mime ();
}
static void
help_callback ()
{
/* Sigh... empty as always */
}
static void
init_mime_capplet ()
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *button;
capplet = capplet_widget_new ();
delete_button = left_aligned_button (_("Delete"));
gtk_signal_connect (GTK_OBJECT (delete_button), "clicked",
delete_clicked, NULL);
hbox = gtk_hbox_new (FALSE, GNOME_PAD);
gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (capplet), hbox);
gtk_box_pack_start (GTK_BOX (hbox), get_mime_clist (), TRUE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
button = left_aligned_button (_("Add..."));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
add_clicked, NULL);
button = left_aligned_button (_("Edit..."));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
edit_clicked, NULL);
gtk_box_pack_start (GTK_BOX (vbox), delete_button, FALSE, FALSE, 0);
gtk_widget_show_all (capplet);
gtk_signal_connect(GTK_OBJECT(capplet), "try",
GTK_SIGNAL_FUNC(try_callback), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "revert",
GTK_SIGNAL_FUNC(revert_callback), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "ok",
GTK_SIGNAL_FUNC(ok_callback), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
GTK_SIGNAL_FUNC(cancel_callback), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "page_hidden",
GTK_SIGNAL_FUNC(hide_edit_window), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "page_shown",
GTK_SIGNAL_FUNC(show_edit_window), NULL);
#if 0
gtk_signal_connect(GTK_OBJECT(capplet), "help",
GTK_SIGNAL_FUNC(help_callback), NULL);
#endif
}
int
main (int argc, char **argv)
{
int init_results;
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
init_results = gnome_capplet_init("mime-type-capplet", VERSION,
argc, argv, NULL, 0, NULL);
if (init_results < 0) {
exit (0);
}
if (init_results == 0) {
init_mime_type ();
init_mime_capplet ();
capplet_gtk_main ();
}
return 0;
}

View File

@@ -1,116 +0,0 @@
#include "new-mime-window.h"
#include "capplet-widget.h"
#include <config.h>
static GtkWidget *add_dialog = NULL;
extern GtkWidget *capplet;
/*Public functions */
void
launch_new_mime_window (void)
{
GtkWidget *mime_entry;
GtkWidget *label;
GtkWidget *frame;
GtkWidget *ext_entry;
GtkWidget *regex1_entry;
GtkWidget *regex2_entry;
GtkWidget *hbox;
GtkWidget *vbox;
GtkWidget *table;
add_dialog = gnome_dialog_new (_("Add Mime Type"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL);
label = gtk_label_new (_("Add a new Mime Type\nFor example: image/tiff; text/x-scheme"));
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Mime Type:"));
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
mime_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), mime_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), hbox, FALSE, FALSE, 0);
frame = gtk_frame_new (_("Extensions"));
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), frame, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
label = gtk_label_new (_("Type in the extensions for this mime-type.\nFor example: .html, .htm"));
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), gtk_label_new (_("Extension:")), FALSE, FALSE, 0);
ext_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), ext_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
frame = gtk_frame_new (_("Regular Expressions"));
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (add_dialog)->vbox), frame, FALSE, FALSE, 0);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
label = gtk_label_new (_("You can set up two regular expressions here to identify the Mime Type\nby. These fields are optional."));
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), gtk_hseparator_new (), FALSE, FALSE, 0);
table = gtk_table_new (2, 2, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), GNOME_PAD_SMALL);
/* gtk_container_set_border_width (GTK_CONTAINER (table), GNOME_PAD_SMALL);*/
label = gtk_label_new (_("First Regular Expression: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_table_attach (GTK_TABLE (table),
label,
0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
regex1_entry = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table),
regex1_entry,
1, 2, 0, 1);
label = gtk_label_new (_("Second Regular Expression: "));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
gtk_table_attach (GTK_TABLE (table),
label,
0, 1, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
regex2_entry = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table),
regex2_entry,
1, 2, 1, 2);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show_all (GNOME_DIALOG (add_dialog)->vbox);
switch (gnome_dialog_run (GNOME_DIALOG (add_dialog))) {
case 0:
capplet_widget_state_changed (CAPPLET_WIDGET (capplet),
TRUE);
add_new_mime_type (gtk_entry_get_text (GTK_ENTRY (mime_entry)),
gtk_entry_get_text (GTK_ENTRY (ext_entry)),
gtk_entry_get_text (GTK_ENTRY (regex1_entry)),
gtk_entry_get_text (GTK_ENTRY (regex2_entry)));
case 1:
gtk_widget_destroy (add_dialog);
default:;
}
add_dialog = NULL;
}
void
hide_new_mime_window (void)
{
if (add_dialog != NULL)
gtk_widget_hide (add_dialog);
}
void
show_new_mime_window (void)
{
if (add_dialog != NULL)
gtk_widget_show (add_dialog);
}

View File

@@ -1,14 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Authors: Jonathan Blandford <jrb@redhat.com>
*/
#include "mime-data.h"
#ifndef _NEW_MIME_WINDOW_H_
#define _NEW_MIME_WINDOW_H_
void launch_new_mime_window (void);
void hide_new_mime_window (void);
void show_new_mime_window (void);
#endif

View File

@@ -1,488 +0,0 @@
2000-07-31 Bradford Hovinen <hovinen@helixcode.com>
* all: Removed ENABLE_{LIBGLADE|CAPPLET|PREVIEW} ifdefs
2000-07-26 Bradford Hovinen <hovinen@helixcode.com>
* src/rc-parse.c (command_exists): Use gnome_is_program_in_path,
return stat results if program is a full path
2000-07-20 Bradford Hovinen <hovinen@helixcode.com>
* src/prefs-widget.c: Include check button xpms
(set_pixmap): Use gdk_pixbuf_new_from_xpm_data
* src/Makefile.am (screensaver_properties_capplet_SOURCES): Put
headers in sources list
(pixmap_DATA): Don't install xpms
(EXTRA_DIST): Add check button xpms
2000-06-25 Bradford Hovinen <hovinen@udel.edu>
* src/prefs-widget.c (screensaver_remove_cb): Select next row, not
next saver in list
* src/selection-dialog.c (place_screensaver_list): Don't crash if
node is null
* src/rc-parse.c (parse_screensaver_list): Code cleanup
* src/selection-dialog.c (place_screensaver_list): Code cleanup
* src/preferences.c (screensaver_remove): Return pointer to new head
of list, take pointer to start of screensaver list,
use g_list_remove_link
* src/prefs-widget.c (screensaver_remove_cb): Get new head pointer
and assign to screensaver list entry, assign widget->selected_saver
(screensaver_prefs_ok_cb): Set text in clist
* src/main.c (demo_cb): Save a copy of prefs_widget->screensavers
in prefs before saving preferences
2000-06-24 Bradford Hovinen <hovinen@udel.edu>
* src/screensaver-prefs-dialog.c (read_boolean): Set toggle button
correctly
* src/expr.c (int_parse_factor): Handle G_TOKEN_IDENTIFIER
* src/screensaver-prefs-dialog.c (read_command_line): Use GScanner
(arg_is_set): Rewrite for sentance parser
* src/expr.c (int_parse_factor): Use g_scanner_error
(parse_sentance):
(int_parse_sentance):
(int_parse_unary):
(int_parse_atom): Implement
2000-06-23 Bradford Hovinen <hovinen@udel.edu>
* src/prefs-widget.c (prefs_widget_init): Tweak table attach
policies for screensaver selection page
* src/main.c (setup_capplet_widget): Set window policy
* src/preview.c (strip_arg):
(setup_path):
(add_window_arg):
(show_screensaver): Compile only if ENABLE_PREVIEW set
* src/prefs-widget.c (prefs_widget_init): Use table for
positioning basic controls
* src/main.c (main): Start xscreensaver only if screensaver is not
disabled
(try_cb):
(revert_cb):
(ok_cb):
(cancel_cb): Start and stop xscreensaver based on whether
screensaver is disabled
* src/screensaver-prefs-dialog.c (get_basic_screensaver_widget):
Add visual combo box, set border width to 5
(screensaver_prefs_dialog_new): Don't set container border width
for frame
(store_cli): Save visual
* src/prefs-widget.c (prefs_widget_init): Set frame border width
after adding scrolled window
* src/preferences.c (preferences_load): Make default selection
mode 3
* src/preferences.h: Add SM_DISABLE_SCREENSAVER and SM_BLANK_SCREEN
* src/prefs-widget.c (prefs_widget_init): Use table for power
management
(prefs_widget_init): Add disable screensaver and black screen only
controls
* src/main.c (setup_capplet_widget): Don't call
prefs_widget_set_screensavers
* src/prefs-widget.c (prefs_widget_get_prefs): Call
prefs_widget_set_screensavers
(prefs_widget_set_screensavers): Clear clist
* src/preview.c: gdk-pixbuf should be mandatory
(show_screensaver): Don't fork off second process
(show_screensaver_timeout): Implement
(close_preview): Clear preview_pid, cancel timeout
(show_preview): Set timeout id
Declare preview_window, preview_pid, and timeout_id only if
preview is enabled
* src/prefs-widget.c (prefs_widget_init): Make viewport
declaration depend on whether ENABLE_PREVIEW is declared
2000-06-22 Bradford Hovinen <hovinen@udel.edu>
* src/preview.c: Removed demo_pid and demo_window
(print_args): Disabled compilation
* src/screensaver-prefs-dialog.c (get_argument_data):
(get_screensaver_widget):
(arg_mapping_exists): Use SSPROP_DATADIR
* src/preview.c (show_screensaver): Use SSPROP_DATADIR
* src/prefs-widget.c (set_pixmap): Use SSPROP_DATADIR
* configure.in (SSPROP_DATADIR): Define
* src/prefs-widget.c (prefs_widget_init): Autosort screensaver list on
column 1
(select_saver_cb):
(deselect_saver_cb):
(create_list_item): Use gtk_clist_{get|set}_row_data
(set_pixmap): Accept row
(set_toggle_buttons_sensitive): Use gtk_clist_get_row_data
(set_screensavers_enabled): Don't call set_pixmap
(set_all_pixmaps): Rename from set_toggle_buttons_sensitive
(one_screensaver_cb):
(random_cb): Don't call set_all_pixmaps
(toggle_saver): Accept row
(demo_next_cb):
(demo_prev_cb): Use gtk_clist_find_row_with_data to get row
(select_row): Implement
(create_list_item): Return row
(prefs_widget_init): Don't create viewport
(prefs_widget_set_screensavers): Find enabled screensaver
manually, freeze and thaw screensaver list
* src/main.c (setup_capplet_widget): Don't sort
* src/prefs-widget.c (deselect_saver_cb):
(toggle_saver): Implement
(set_pixmap): Create pixmaps here, use GdkPixbuf
(prefs_widget_store_prefs): Store selection mode
(set_pixmap):
(set_toggle_buttons_sensitive): Pass selection mode
(prefs_widget_set_screensavers):
(demo_next_cb):
(demo_prev_cb):
(screensaver_remove_cb):
(one_screensaver_cb):
(add_select_cb): Call gtk_clist_moveto after selecting widget
* src/preferences.h (struct _Screensaver ): Remove widgets
* src/prefs-widget.c (prefs_widget_class_init): Set up pixmaps for
screensaver list
(prefs_widget_init): Construct clist for screensaver_list, connect
signal for selecting rows
(create_list_item):
(add_select_cb):
(prefs_widget_set_screensavers):
(select_saver_cb):
(set_toggle_buttons_sensitive):
(set_screensavers_enabled):
(choose_from_selected_cb):
(demo_next_cb):
(demo_prev_cb): Rewrite for clist
(demo_next_cb):
(demo_prev_cb): Don't stop preview
(screensaver_toggle_cb): Remove
(prefs_widget_init): Remove disabled code
* src/preferences.c (get_selection_mode): Remove
(preferences_load):
(preferences_save): Use gnome_config to store selection mode
(preferences_destroy):
(screensaver_destroy): Don't act if object is NULL
(preferences_load):
(preferences_save):
(screensaver_add):
(screensaver_remove):
(screensaver_get_desc): Add assertions
* src/prefs-widget.c (choose_from_selected_cb): Check off active
screensaver when moving from one screensaver only mode to choose
from selected mode
* configure.in: Eliminate option to use xscreensaver command to
start demo (made mandatory)
* src/preview.c (show_screensaver): Lower priority on preview
(show_demo): Don't close preview when showing demo
Eliminate version of show_demo that calls screensaver directly
* src/prefs-widget.c (prefs_widget_init): Make priority range from -20
to 0
2000-06-21 Bradford Hovinen <hovinen@udel.edu>
* src/pref-file.c (get_line): Don't subtract off len, don't use len-2
when doing line number increase test
* src/prefs-widget.c (prefs_widget_init): Change "selected" to
"checked off"
* src/main.c (setup_capplet_widget): Set screensavers after showing
the widget
* src/prefs-widget.c (demo_next_cb):
(demo_prev_cb): Kill off the preview
(set_screensavers_enabled): Implement
(random_cb): Enable all screensavers
(one_screensaver_cb): Disable all screensavers, then select the
first one if none selected
(prefs_widget_set_screensavers): Select enabled item when in one
screensaver only mode
* src/screensaver-prefs-dialog.c (screensaver_prefs_dialog_init): Add
help button
(help_cb): Implement
* src/prefs-widget.c (prefs_demo_cb): Implement
* src/screensaver-prefs-dialog.c (get_basic_screensaver_widget):
Remove message to choose a screensaver from the list, set padding
to 5 pixels
(arg_mapping_exists): Return FALSE if name is NULL
(screensaver_prefs_dialog_init): Add demo button
(screensaver_prefs_dialog_new): Connect demo button signal
(store_cli):
(demo_cb): Implement
(screensaver_prefs_dialog_class_init): Add signal demo
* src/preferences.c (screensaver_get_desc): Set screensaver
description to default value if it cannot be found
* src/selection-dialog.c (selection_dialog_ok_cb): Use g_strdup for
name, set name and command_line only when selected node is valid
* src/preferences.c (screensaver_add): Implement
* src/prefs-widget.c (screensaver_add_cb): Use SelectionDialog
(create_list_item): Implement
(add_select_cb): Select the item just created
* src/selection-dialog.c (selection_dialog_get_type):
(selection_dialog_init):
(selection_dialog_class_init):
(selection_dialog_new):
(select_program_cb):
(selection_dialog_ok_cb):
(selection_dialog_cancel_cb):
(append_list_item): Implement
* src/prefs-widget.c (prefs_widget_set_screensavers): Make item a
member of the saver
* src/preferences.c (screensaver_destroy): Don't remove link from
list; assume that's already done
(screensaver_remove): Don't destroy screensaver
* src/prefs-widget.c (prefs_widget_store_prefs): Use
gtk_spin_button_get_value_as_{float|int}
(make_screensaver_selection_dialog):
(add_cancel_cb):
(add_select_cb): Implement
* src/preferences.c (store_prefs_in_db):
(read_prefs_from_db): Remove password timeout
* src/rc-parse.c (write_minutes): Accept gdouble
(parse_minutes_resource): Return gdouble
* src/preferences.h (struct _Preferences ): Make timeouts doubles
* src/prefs-widget.c (prefs_widget_set_screensavers): Use member
label_widget rather than auto label
(prefs_widget_init): Remove controls dealing with password
timeout, make lock timeout in minutes
* src/preferences.c (screensaver_remove): Implement
* src/prefs-widget.c (prefs_widget_init): Add demo previous button
(demo_prev_cb): Implement
* src/rc-parse.c (parse_screensaver_list): Use our own procedure to
append the item to the end of the list
* src/prefs-widget.c (demo_next_cb):
(settings_cb): Check if a screensaver is selected before proceeding
(demo_next_cb): Implement
* src/rc-parse.c (parse_screensaver_list): Set saver->link
* src/prefs-widget.c (prefs_widget_init): Make remove button a member
of the structure
(select_saver_cb): Sensitive remove_button
(prefs_widget_init): Add demo next button
* src/preview.c (find_xscreensaver_window): Fixed up the code to
trap errors better
2000-06-20 Bradford Hovinen <hovinen@udel.edu>
* src/screensaver-prefs-dialog.c (screensaver_prefs_dialog_init): Add
code to support name entry
(screensaver_prefs_dialog_new): Set name entry to label, add
preferences widget only if it exists, make basic_widget an element
of the structure
(screensaver_prop_ok_cb): Set label from name entry, free old
command line and label, use g_strdup when getting text from entries
(add_screensaver_selector): Implement
(get_basic_screensaver_widget): Use a different label if the
screensaver is not yet defined
* src/prefs-widget.c (set_standby_time_sensitive):
(set_suspend_time_sensitive):
(set_power_controls_sensitive): Implement
(set_power_down_time_sensitive): Disable only the control, not the
labels
(power_management_toggled_cb): Use set_power_controls_sensitive
(prefs_widget_get_prefs): Code cleanup
* src/daemon.c (setup_dpms): Use standby and suspend times, add
prefs->timeout, sanitize values before sending to xset, return if
power management disabled
* src/preferences.c (preferences_load):
(preferences_save): Load/save standby and suspend times
* src/prefs-widget.c (prefs_widget_init): Remove extraneous code, add
support for all dpms timings
(prefs_widget_store_prefs):
(prefs_widget_get_prefs): Read/store standby and suspend times
* src/daemon.c (setup_dpms): Don't call the command to enable dpms,
use unsigned formats, multiply times by 60
* src/main.c (state_changed_cb):
(try_cb):
(revert_cb):
(ok_cb): Call setup_dpms
* src/rc-parse.c (get_settings_name):
(get_label): Use g_strdup rather than strdup
* src/pref-file.c (preferences_save_to_file):
(write_entry): Use g_file_test rather than stat
* src/main.c (main): Set up to start xscreensaver on startup
* src/rc-parse.c (get_settings_name): Use g_basename
(command_exists): Use g_file_test rather than stat
(parse_boolean_resource): Use g_strncasecmp
* src/pref-file.c (init_file_name): Use g_concat_dir_and_file and
g_get_home_dir
* src/daemon.c (start_xscreensaver):
(stop_xscreensaver):
(restart_xscreensaver):
(setup_dpms): Use gnome_execute_shell rather than system
* src/main.c (cancel_cb):
(ok_cb):
(revert_cb):
(try_cb): Don't restart xscreensaver
* src/prefs-widget.c (prefs_widget_get_prefs): Don't divide minute
values by 60 before displaying
(prefs_widget_store_prefs): Don't multiply minute values by 60
before storing
* src/pref-file.c (preferences_save_to_file): Use g_warning rather
than sprintf and perror
(parse_config_file): Use g_warning directly rather than
g_strdup_printf
* src/preferences.h (struct _Preferences ): Change be_verbose to
verbose
* src/preferences.c (preferences_get_screensaver_list): Remove
(preferences_load): Call read_prefs_from_db
(preferences_save): Call store_prefs_in_db
(read_prefs_from_db):
(store_prefs_in_db): Implement
* src/rc-parse.c (format_command):
(stab_to):
(string_columns):
(format_hack): Move to rc-parse.c
(write_screensaver_list): Implement; copy from pref-file.c,
preferences_save_to_file
(write_screensaver_list): Fixed memory leak with output from
format_hack
* src/pref-file.c (preferences_save_to_file): Remove code to write out
programs resource string
* src/preferences.c (preferences_destroy): Remove check on prefs->shell
* src/prefs-widget.c (prefs_widget_init): Remove lock_vts widget
2000-06-19 Bradford Hovinen <hovinen@udel.edu>
* src/prefs-widget.c (prefs_widget_init): Create GtkText
prefs->description rather than prefs->description_label; put
inside a scrolled window
(select_saver_cb): Fill GtkText with description
(set_description_text): Implement
* src/preview.c (show_demo): Make xscreensaver_window automatic
* src/prefs-widget.c (prefs_widget_class_init): New signal:
activate-demo
(demo_cb): Emit activate-demo signal
* src/main.c (setup_capplet_widget): Connect activate-demo signal
* src/preview.c (find_xscreensaver_window): Use free rather than
g_free for data allocated by Xlib
(show_demo): Free allocated event structure
* src/pref-file.c: Use g_strstrip rather than strip
(transform_line): Add default action to copy escaped character over
* src/rc-parse.c (command_exists): Check for string termination when
looking for the first whitespace
* src/resources.c (get_resource): Use g_strconcat rather than strcpy
and strcat
* src/rc-parse.c (parse_screensaver): Use g_strdup rather than malloc
and strncpy
* src/screensaver-prefs-dialog.c (arg_mapping_exists): Implement
(screensaver_prefs_dialog_new): Check if glade definition exists
before trying to load data
* src/pref-file.c (transform_line): Terminate loop when i > len
(strip): Code cleanup
(init_file_name):
(init_file_tmp_name): Use g_strconcat rather than legacy functions
* src/prefs-widget.c (prefs_widget_init): Add line to set data type
for fade_ticks_widget to integer
2000-06-18 Bradford Hovinen <hovinen@udel.edu>
* src/pref-file.c (place_preferences): Delete
(preferences_load_from_file): Return gboolean rather than int
(preferences_save_to_file): Use g_tree_traverse on config_db
(write_preference_cb): Implement
(preferences_save_to_file): Store programs resource in config_db
after building it
(transform_line): Added support for backslash escape
* src/resources.c (preferences_load_from_xrdb): Update to use
config_db
(get_string_resource): Rename to get_resource
* src/pref-file.c (preferences_load_from_file): Use GTree for
config_db rather than GHashTable
* src/prefs-widget.c (prefs_widget_init): Put preview above
description
* src/preferences.h (struct _Preferences ): Add config_db
* src/screensaver-prefs-dialog.c (screensaver_prefs_dialog_new): Set
dialog title to label + " properties"

View File

@@ -1,50 +0,0 @@
pixmapdir = $(datadir)/pixmaps
pixmap_DATA = \
no-hack.png
Applicationsdir = $(datadir)/control-center/Desktop
Applications_DATA = \
screensaver-properties.desktop
SUBDIRS = screensavers
EXTRA_DIST = ChangeLog TODO $(Applications_DATA) $(pixmap_DATA) \
checked.xpm unchecked.xpm checked-disabled.xpm unchecked-disabled.xpm
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-DSSPROP_DATADIR=\""${prefix}/share/screensaver-properties"\" \
-DG_LOG_DOMAIN=\"screensaver-properties\" \
$(GNOME_INCLUDEDIR) \
$(LIBGLADE_CFLAGS) \
$(XML_CFLAGS) \
-I$(top_srcdir)/
-I../intl
-I$(top_srcdir)/intl
-I$(top_srcdir)/control-center
bin_PROGRAMS = screensaver-properties-capplet
screensaver_properties_capplet_SOURCES = \
prefs-widget.c prefs-widget.h\
preferences.c preferences.h\
screensaver-prefs-dialog.c screensaver-prefs-dialog.h\
selection-dialog.c selection-dialog.h \
pref-file.c pref-file.h \
preview.c preview.h \
expr.c expr.h \
daemon.c daemon.h \
rc-parse.c rc-parse.h \
resources.c resources.h \
XScreenSaver_ad.h \
main.c
screensaver_properties_capplet_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(ORBIT_LIBS) \
$(LIBGLADE_LIBS) \
$(GNOME_XML_LIB) \
-lXt \
-lgdk_pixbuf \
../../control-center/libcapplet.la

View File

@@ -1,952 +0,0 @@
"#error Do not run app-defaults files through xrdb!",
"#error That does not do what you might expect.",
"#error Put this file in /usr/lib/X11/app-defaults/XScreenSaver instead.",
"*timeout: 10",
"*cycle: 10",
"*lockTimeout: 0",
"*passwdTimeout: 30",
"*nice: 10",
"*lock: False",
"*lockVTs: True",
"*verbose: False",
"*timestamp: False",
"*fade: True",
"*unfade: False",
"*fadeSeconds: 3",
"*fadeTicks: 20",
"*splash: True",
"*splashDuration: 5",
"*visualID: default",
"*captureStderr: True",
"*overlayTextForeground: #FFFF00",
"*overlayTextBackground: #000000",
"*overlayStderr: True",
"*font: *-medium-r-*-140-*-m-*",
"*sgiSaverExtension: True",
"*mitSaverExtension: False",
"*xidleExtension: True",
"*procInterrupts: True",
"*demoCommand: xscreensaver-demo",
"*prefsCommand: xscreensaver-demo -prefs",
"*helpURL: http://www.jwz.org/xscreensaver/man.html",
"*loadURL: netscape -remote 'openURL(%s)' || netscape '%s'",
"*manualCommand: xterm +sb -fg black -bg gray75 -T '%s manual' \
-e /bin/sh -c 'man \"%s\" || read foo'",
"*dateFormat: %d-%b-%y (%a); %I:%M %p",
"*installColormap: True",
"*programs: \
\"Qix (solid)\" qix -root -solid -delay 0 -segments 100 \\n\
\"Qix (transparent)\" qix -root -count 4 -solid -transparent \\n\
\"Qix (linear)\" qix -root -count 5 -solid -transparent \
-linear -segments 250 -size 100 \\n\
- mono: \"Qix (xor)\" qix -root -linear -count 5 -size 200 \
-spread 30 -segments 75 -solid -xor \\n\
\
\"Attraction (balls)\" attraction -root -mode balls \\n\
\"Attraction (lines)\" attraction -root -mode lines -points 3 \
-segments 200 \\n\
- \"Attraction (poly)\" attraction -root -mode polygons \\n\
\"Attraction (splines)\" attraction -root -mode splines -segments \
300 \\n\
\"Attraction (orbital)\" attraction -root -mode lines -radius 300 \
-orbit -vmult 0.5 \\n\
\
pyro -root \\n\
rocks -root \\n\
helix -root \\n\
pedal -root \\n\
rorschach -root -offset 7 \\n\
hopalong -root \\n\
greynetic -root \\n\
xroger -root \\n\
imsmap -root \\n\
slidescreen -root \\n\
decayscreen -root \\n\
jigsaw -root \\n\
blitspin -root -grab \\n\
slip -root \\n\
distort -root \\n\
spotlight -root \\n\
\"Ripples (oily)\" ripples -root -oily -light 2 \\n\
\"Ripples (stir)\" ripples -root -oily -light 2 -stir \\n\
\"Ripples (desktop)\" ripples -root -water -light 6 \\n\
hypercube -root \\n\
halo -root \\n\
maze -root \\n\
noseguy -root \\n\
flame -root \\n\
lmorph -root \\n\
deco -root \\n\
moire -root \\n\
moire2 -root \\n\
lightning -root \\n\
strange -root \\n\
spiral -root \\n\
laser -root \\n\
grav -root \\n\
\"Grav (trails)\" grav -root -trail -decay \\n\
drift -root \\n\
ifs -root \\n\
julia -root \\n\
penrose -root \\n\
sierpinski -root \\n\
braid -root \\n\
galaxy -root \\n\
bouboule -root \\n\
swirl -root \\n\
flag -root \\n\
sphere -root \\n\
forest -root \\n\
lisa -root \\n\
lissie -root \\n\
goop -root -max-velocity 0.5 -elasticity \
0.9 \\n\
starfish -root \\n\
\"Starfish (blob)\" starfish -root -blob \\n\
munch -root \\n\
fadeplot -root \\n\
coral -root -delay 0 \\n\
mountain -root \\n\
triangle -root -delay 1 \\n\
worm -root \\n\
rotor -root \\n\
ant -root \\n\
demon -root \\n\
loop -root \\n\
vines -root \\n\
kaleidescope -root \\n\
xjack -root \\n\
xlyap -root -randomize \\n\
cynosure -root \\n\
flow -root \\n\
epicycle -root \\n\
interference -root \\n\
truchet -root -randomize \\n\
bsod -root \\n\
crystal -root \\n\
discrete -root \\n\
kumppa -root \\n\
rd-bomb -root \\n\
\"RD-Bomb (mobile)\" rd-bomb -root -speed 1 -size 0.1 \\n\
sonar -root \\n\
t3d -root \\n\
penetrate -root \\n\
deluxe -root \\n\
compass -root \\n\
squiral -root \\n\
xflame -root \\n\
wander -root \\n\
\"Wander (spots)\" wander -root -advance 0 -size 10 -circles \
True -length 10000 -reset 100000 \\n\
critical -root \\n\
phosphor -root \\n\
xmatrix -root \\n\
petri -root -size 2 -count 20 \\n\
\"Petri 2\" petri -root -minlifespeed 0.02 \
-maxlifespeed 0.03 -minlifespan 1 \
-maxlifespan 1 -instantdeathchan 0 \
-minorchan 0 -anychan 0.3 \\n\
shadebobs -root \\n\
ccurve -root \\n\
blaster -root \\n\
bumps -root \\n\
xteevee -root \\n\
xspirograph -root \\n\
color: bubbles -root \\n\
default-n: webcollage -root \\n\
default-n: \"WebCollage (whacked)\" \
webcollage -root -filter \
'vidwhacker -stdin -stdout' \\n\
- default-n: vidwhacker -root \\n\
\
GL: gears -root \\n\
GL: superquadrics -root \\n\
GL: morph3d -root \\n\
GL: cage -root \\n\
GL: moebius -root \\n\
GL: stairs -root \\n\
GL: pipes -root \\n\
GL: sproingies -root \\n\
GL: rubik -root \\n\
GL: atlantis -root \\n\
GL: lament -root \\n\
GL: bubble3d -root \\n\
GL: glplanet -root \\n\
GL: pulsar -root \\n\
- GL: \"Pulsar (textures)\" \
pulsar -root -texture -mipmap \
-texture_quality -light -fog \\n\
GL: extrusion -root \\n\
GL: sierpinski3d -root \\n\
GL: starwars -root \\n\
\
- xdaliclock -root -builtin3 -cycle \\n\
- default-n: xearth -nofork -nostars -ncolors 50 \
-night 3 -wait 0 -timewarp 400.0 -pos \
sunrel/38/-30 \\n\
- ssystem -fullscreen :32 \\n\
- xmountains -b -M -Z 0 -r 1 \\n\
- \"XMountains (top)\" xmountains -b -M -Z 0 -r 1 -m \\n\
- xaos -root -autopilot -incoloring -1 \
-nogui -outcoloring -1 \\n\
- xfishtank -d -s \\n\
- xsnow \\n\
- goban -root \\n\
- electricsheep \\n",
"XScreenSaver.pointerPollTime: 5",
"XScreenSaver.initialDelay: 0",
"XScreenSaver.windowCreationTimeout: 30",
"XScreenSaver.bourneShell: /bin/sh",
"*Dialog.headingFont: *-times-bold-r-*-*-*-180-*-*-*-iso8859-1",
"*Dialog.bodyFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
"*Dialog.labelFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
"*Dialog.buttonFont: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
"*Dialog.dateFont: *-courier-medium-r-*-*-*-80-*-*-*-iso8859-1",
"*Dialog.foreground: #000000",
"*Dialog.background: #BFBFBF",
"*Dialog.Button.foreground: #000000",
"*Dialog.Button.background: #D0D0D0",
"*Dialog.text.foreground: #000000",
"*Dialog.text.background: #FFFFFF",
"*Dialog.logo.foreground: #FF0000",
"*Dialog.logo.background: #FFFFFF",
"*Dialog.topShadowColor: #E7E7E7",
"*Dialog.bottomShadowColor: #737373",
"*Dialog.logo.width: 200",
"*Dialog.logo.height: 200",
"*Dialog.internalBorderWidth: 30",
"*Dialog.borderWidth: 1",
"*Dialog.shadowThickness: 4",
"*passwd.heading.label: XScreenSaver %s",
"*passwd.body.label: This display is locked.",
"*passwd.user.label: User:",
"*passwd.passwd.label: Password:",
"*passwd.passwdFont: *-courier-medium-r-*-*-*-140-*-*-*-iso8859-1",
"*passwd.thermometer.width: 8",
"*splash.heading.label: XScreenSaver %s",
"*splash.body.label: Copyright © 1991-1999 by",
"*splash.body2.label: Jamie Zawinski <jwz@jwz.org>",
"*splash.demo.label: Demo",
"*splash.prefs.label: Prefs",
"*splash.help.label: Help",
"*fontList: *-helvetica-medium-r-*-*-*-120-*-*-*-iso8859-1",
"*demoDialog*label1.fontList: *-helvetica-medium-r-*-*-*-140-*-*-*-iso8859-1",
"*cmdText.fontList: *-courier-medium-r-*-*-*-120-*-*-*-iso8859-1",
"*label0.fontList: *-helvetica-bold-r-*-*-*-140-*-*-*-iso8859-1",
"XScreenSaver*doc.fontList: *-helvetica-medium-r-*-*-*-100-*-*-*-iso8859-1",
"*foreground: #000000",
"*background: #C0C0C0",
"*XmTextField.foreground: #000000",
"*XmTextField.background: #FFFFFF",
"*list.foreground: #000000",
"*list.background: #FFFFFF",
"*ApplicationShell.title: XScreenSaver",
"*warning.title: XScreenSaver",
"*warning_popup.title: XScreenSaver",
"*allowShellResize: True",
"*autoUnmanage: False",
"*menubar*file.labelString: File",
"*menubar*file.mnemonic: F",
"*file.blank.labelString: Blank Screen Now",
"*file.blank.mnemonic: B",
"*file.lock.labelString: Lock Screen Now",
"*file.lock.mnemonic: L",
"*file.kill.labelString: Kill Daemon",
"*file.kill.mnemonic: K",
"*file.restart.labelString: Restart Daemon",
"*file.restart.mnemonic: R",
"*file.exit.labelString: Exit",
"*file.exit.mnemonic: E",
"*menubar*edit.labelString: Edit",
"*menubar*edit.mnemonic: E",
"*edit.cut.labelString: Cut",
"*edit.cut.mnemonic: u",
"*edit.copy.labelString: Copy",
"*edit.copy.mnemonic: C",
"*edit.paste.labelString: Paste",
"*edit.paste.mnemonic: P",
"*menubar*help.labelString: Help",
"*menubar*help.mnemonic: H",
"*help.about.labelString: About...",
"*help.about.mnemonic: A",
"*help.docMenu.labelString: Documentation...",
"*help.docMenu.mnemonic: D",
"*demoTab.marginWidth: 10",
"*optionsTab.marginWidth: 10",
"*XmScrolledWindow.topOffset: 10",
"*XmScrolledWindow.leftOffset: 10",
"*demoTab.topOffset: 4",
"*form1.bottomOffset: 10",
"*form3.leftOffset: 10",
"*form3.rightOffset: 10",
"*frame.topOffset: 10",
"*frame.bottomOffset: 10",
"*enabled.topOffset: 10",
"*visLabel.topOffset: 10",
"*combo.topOffset: 10",
"*form4.bottomOffset: 4",
"*hr.bottomOffset: 4",
"*XmComboBox.marginWidth: 0",
"*XmComboBox.marginHeight: 0",
"*demo.marginWidth: 30",
"*demo.marginHeight: 4",
"*man.marginWidth: 10",
"*man.marginHeight: 4",
"*down.leftOffset: 40",
"*down.marginWidth: 4",
"*down.marginHeight: 4",
"*up.marginWidth: 4",
"*up.marginHeight: 4",
"*frame.traversalOn: False",
"*list.automaticSelection: True",
"*list.visibleItemCount: 20",
"*doc.columns: 60",
"*combo.columns: 11",
"*demoTab.labelString: Graphics Demos",
"*optionsTab.labelString: Screensaver Options",
"*down.labelString: \\\\/ ",
"*up.labelString: /\\\\ ",
"*frameLabel.labelString: ",
"*cmdLabel.labelString: Command Line:",
"*cmdLabel.alignment: ALIGNMENT_BEGINNING",
"*enabled.labelString: Enabled",
"*visLabel.labelString: Visual:",
"*visLabel.alignment: ALIGNMENT_END",
"*visLabel.leftOffset: 20",
"*demo.labelString: Demo",
"*man.labelString: Documentation...",
"*done.labelString: Quit",
"*preferencesLabel.labelString: XScreenSaver Parameters",
"*timeoutLabel.labelString: Saver Timeout",
"*cycleLabel.labelString: Cycle Timeout",
"*fadeSecondsLabel.labelString: Fade Duration",
"*fadeTicksLabel.labelString: Fade Ticks",
"*lockLabel.labelString: Lock Timeout",
"*passwdLabel.labelString: Password Timeout",
"*preferencesForm*XmTextField.columns: 8",
"*verboseToggle.labelString: Verbose",
"*cmapToggle.labelString: Install Colormap",
"*fadeToggle.labelString: Fade Colormap",
"*unfadeToggle.labelString: Unfade Colormap",
"*lockToggle.labelString: Require Password",
"*OK.marginWidth: 30",
"*OK.marginHeight: 4",
"*OK.leftOffset: 10",
"*OK.bottomOffset: 10",
"*Cancel.marginWidth: 30",
"*Cancel.marginHeight: 4",
"*Cancel.rightOffset: 10",
"*Cancel.bottomOffset: 10",
"*hacks.documentation.isInstalled: True",
"*hacks.qix.documentation: \
This is the swiss army chainsaw of qix programs. It bounces a series \
of line segments around the screen, and uses variations on this basic \
motion pattern to produce all sorts of different presentations: line \
segments, filled polygons, overlapping translucent areas... Written \
by Jamie Zawinski.",
"*hacks.attraction.documentation: \
Like qix, this uses a simple simple motion model to generate many \
different display modes. The control points attract each other up to \
a certain distance, and then begin to repel each other. The \
attraction/repulsion is proportional to the distance between any two \
particles, similar to the strong and weak nuclear forces. \
\\n\\n\
One of the most interesting ways to watch this hack is simply as \
bouncing balls, because their motions and interactions with each \
other are so odd. Sometimes two balls will get into a tight orbit \
around each other, to be interrupted later by a third, or by the edge \
of the screen. It looks quite chaotic. \
\\n\\n\
Written by Jamie Zawinski, based on Lisp code by John Pezaris.",
"*hacks.pyro.documentation: \
Pyro draws exploding fireworks. Blah blah blah. Written by Jamie \
Zawinski.",
"*hacks.helix.documentation: \
This repeatedly generates spirally string-art-ish patterns. Written \
by Jamie Zawinski.",
"*hacks.pedal.documentation: \
This is sort of a combination spirograph/string-art. It generates a \
large, complex polygon, and lets the X server do the bulk of the work \
by giving it an even/odd winding rule. Written by Dale Moore, based \
on some ancient PDP-11 code.",
"*hacks.rorschach.documentation: \
This generates random inkblot patterns. The algorithm is deceptively \
simple for how well it works; it merely walks a dot around the screen \
randomly, and then reflects the image horizontally, vertically, or \
both. Any deep-seated neurotic tendencies which this program reveals \
are your own problem. Written by Jamie Zawinski.",
"*hacks.hopalong.documentation: \
This draws lacy fractal patterns, based on iteration in the imaginary \
plane, from a 1986 Scientific American article. Mostly written by \
Patrick Naughton.",
"*hacks.greynetic.documentation: \
This draws random colored and stippled rectangles. Written by Jamie \
Zawinski.",
"*hacks.xroger.documentation: \
The XScreenSaver logo. Don't you hate it? So do I. Would you like \
to design a new logo for XScreenSaver? If so, send jwz your \
submissions.",
"*hacks.imsmap.name: IMSmap",
"*hacks.imsmap.documentation: \
This generates random cloud-like patterns. It looks quite different \
in monochrome and color. The basic idea is to take four points on \
the edge of the image, and assign each a random ``elevation''. Then \
find the point between them, and give it a value which is the average \
of the other four, plus some small random offset. Then coloration is \
done based on elevation. \
\\n\\n\
The color selection is done by binding the elevation to either hue, \
saturation, or brightness, and assigning random values to the others. \
The ``brightness'' mode tends to yield cloudlike patterns, and the \
others tend to generate images that look like heat-maps or CAT-scans. \
Written by Juergen Nickelsen and Jamie Zawinski.",
"*hacks.slidescreen.name: SlideScreen",
"*hacks.slidescreen.documentation: \
This grabs an image of whatever is on your screen, divides it into a \
grid, and then randomly shuffles the squares around as if it was one \
of those annoying ``16-puzzle'' games, where there is a grid of \
squares, one of which is missing. I hate trying to solve those \
puzzles, but watching one permute itself is more amusing. Written by \
Jamie Zawinski.",
"*hacks.decayscreen.name: DecayScreen",
"*hacks.decayscreen.documentation: \
This grabs an image of whatever is on your screen, and makes it melt. \
You've no doubt seen this effect before, but no screensaver would \
really be complete without it. It works best if there's something \
colorful visible. Warning, if the effect continues after the screen \
saver is off, seek medical attention. Written by David Wald and \
Vivek Khera. \
\\n\\n\
A number of these screenhacks have the ability to take an image of \
your desktop and manipulate it in some way. On SGI systems, these \
programs are able to (at random) pull their source image from the \
system's video input instead! This works nicely if you leave some \
some random television station plugged in.",
"*hacks.jigsaw.documentation: \
This grabs a screen image, carves it up into a jigsaw puzzle, \
shuffles it, and then solves the puzzle. This works especially well \
when you feed it an external video signal instead of letting it grab \
the screen image (actually, I guess this is generally true...) When \
it is grabbing a video image, it is sometimes pretty hard to guess \
what the image is going to look like once the puzzle is solved. \
Written by Jamie Zawinski.",
"*hacks.blitspin.name: BlitSpin",
"*hacks.blitspin.documentation: \
The ``blitspin'' hack repeatedly rotates a bitmap by 90 degrees by \
using logical operations: the bitmap is divided into quadrants, and \
the quadrants are shifted clockwise. Then the same thing is done \
again with progressively smaller quadrants, except that all \
sub-quadrants of a given size are rotated in parallel. Written by \
Jamie Zawinski based on some cool SmallTalk code seen in in Byte \
Magazine in 1981. \
\\n\\n\
As you watch it, the image appears to dissolve into static and then \
reconstitute itself, but rotated. You can provide the image to use, \
as an XBM or XPM file, or tell it to grab a screen image and rotate \
that.",
"*hacks.slip.documentation: \
This program throws some random bits on the screen, then sucks them \
through a jet engine and spews them out the other side. To avoid \
turning the image completely to mush, every now and then it will and \
then it interjects some splashes of color into the scene, or go into \
a spin cycle, or stretch the image like taffy, or (this is my \
addition) grab an image of your current desktop to chew on. \
Originally written by Scott Draves; whacked on by Jamie Zawinski.",
"*hacks.distort.documentation: \
This hack grabs an image of the screen, and then lets a transparent \
lens wander around the screen, magnifying whatever is underneath. \
Written by Jonas Munsin.",
"*hacks.spotlight.documentation: \
Draws a spotlight scanning across a black screen, illumnating the \
underlying desktop when it passes. Written by Rick Schultz.",
"*hacks.hypercube.documentation: \
This displays 2D projections of the sequence of 3D objects which are \
the projections of the 4D analog to the cube: as a square is composed \
of four lines, each touching two others; and a cube is composed of \
six squares, each touching four others; a hypercube is composed of \
eight cubes, each touching six others. To make it easier to \
visualize the rotation, it uses a different color for the edges of \
each face. Don't think about it too long, or your brain will melt. \
Written by Joe Keane, Fritz Mueller, and Jamie Zawinski.",
"*hacks.halo.documentation: \
This draws trippy psychedelic circular patterns that hurt to look at. \
It can also animate the control-points, but that takes a lot of CPU \
and bandwidth. Written by Jamie Zawinski.",
"*hacks.maze.documentation: \
This is the ancient X maze demo, modified to work with xscreensaver. \
It generates a random maze, then solves it with visual feedback. \
Originally by Jim Randell; modified by a cast of thousands.",
"*hacks.noseguy.documentation: \
A little man with a big nose wanders around your screen saying \
things. The things which he says can come from a file, or from an \
external program like `zippy' or `fortune'. This was extracted from \
`xnlock' by Dan Heller. Colorized by Jamie Zawinski.",
"*hacks.flame.documentation: \
Another iterative fractal generator. Written by Scott Draves.",
"*hacks.lmorph.name: LMorph",
"*hacks.lmorph.documentation: \
This generates random spline-ish line drawings and morphs between \
them. Written by Sverre H. Huseby and Glenn T. Lines.",
"*hacks.deco.documentation: \
This one subdivides and colors rectangles randomly. It looks kind of \
like Brady-Bunch-era rec-room wall paneling. (Raven says: ``this \
screensaver is ugly enough to peel paint.'') Written by Jamie \
Zawinski, inspired by Java code by Michael Bayne.",
"*hacks.moire.documentation: \
This one draws cool circular interference patterns. Most of the \
circles you see aren't explicitly rendered, but show up as a result \
of interactions between the other pixels that were drawn. Written by \
Jamie Zawinski, inspired by Java code by Michael Bayne. As he \
pointed out, the beauty of this one is that the heart of the display \
algorithm can be expressed with just a pair of loops and a handful of \
arithmetic, giving it a high ``display hack metric''.",
"*hacks.moire2.documentation: \
Another example of the fun you can have with moire \
interference patterns; this hack generates fields of concentric \
circles or ovals, and combines the planes with various operations. \
The planes are moving independently of one another, causing the \
interference lines to ``spray.'' Written by Jamie Zawinski.",
"*hacks.lightning.documentation: \
This one draws crackling fractal lightning bolts. It's simple, \
direct, and to the point. If only it had sound... Written by Keith \
Romberg.",
"*hacks.strange.documentation: \
This draws strange attractors: it's a colorful, \
unpredictably-animating field of dots that swoops and twists around. \
The motion is very nice. Written by Massimino Pascal.",
"*hacks.spiral.documentation: \
Moving circular patterns, by Peter Schmitzberger. Moving circular \
patterns means moire; interference patterns, of course.",
"*hacks.laser.documentation: \
Moving radiating lines, that look vaguely like scanning laser beams. \
Written by Pascal Pensa. (Frankie say: relax.)",
"*hacks.grav.documentation: \
This program draws a simple orbital simulation. If you turn on \
trails, it looks kind of like a cloud-chamber photograph. Written \
by Greg Bowering.",
"*hacks.drift.documentation: \
How could one possibly describe this except as ``drifting recursive \
fractal cosmic flames?'' Another fine hack from the Scott Draves \
collection of fine hacks.",
"*hacks.ifs.name: IFS",
"*hacks.ifs.documentation: \
This one draws spinning, colliding iterated-function-system images. \
Written by Massimino Pascal.",
"*hacks.julia.documentation: \
This one draws spinning, animating (are you detecting a pattern here \
yet?) explorations of the Julia set. You've probably seen static \
images of this fractal form before, but it's a lot of fun to watch in \
motion as well. One interesting thing is that there is a small \
swinging dot passing in front of the image, which indicates the \
control point from which the rest of the image was generated. \
Written by Sean McCullough.",
"*hacks.penrose.documentation: \
Draws quasiperiodic tilings; think of the implications on modern \
formica technology. Written by Timo Korvola. \
\\n\\n\
In April 1997, Sir Roger Penrose, a British math professor who has \
worked with Stephen Hawking on such topics as relativity, black \
holes, and whether time has a beginning, filed a \
copyright-infringement lawsuit against the Kimberly-Clark \
Corporation, which Penrose said copied a pattern he created (a \
pattern demonstrating that ``a nonrepeating pattern could exist in \
nature'') for its Kleenex quilted toilet paper. Penrose said he \
doesn't like litigation but, ``When it comes to the population of \
Great Britain being invited by a multinational to wipe their bottoms \
on what appears to be the work of a Knight of the Realm, then a last \
stand must be taken.'' \
\\n\\n\
As reported by News of the Weird #491, 4-jul-1997.",
"*hacks.sierpinski.documentation: \
This draws the two-dimensional variant of the recursive Sierpinski \
triangle fractal. Written by Desmond Daignault.",
"*hacks.braid.documentation: \
Draws random color-cycling inter-braided concentric circles. Written \
by John Neil.",
"*hacks.galaxy.documentation: \
This draws spinning galaxies, which then collide and scatter their \
stars to the, uh, four winds or something. Originally an Amiga \
program by Uli Siegmund.",
"*hacks.bouboule.documentation: \
This draws what looks like a spinning, deforming baloon with \
varying-sized spots painted on its invisible surface. Written by \
Jeremie Petit.",
"*hacks.swirl.documentation: \
More flowing, swirly patterns. This version is by M. Dobie and R. \
Taylor, but you might have seen a Mac program similar to this called \
FlowFazer. There is also a cool Java applet of a similar concept",
"*hacks.flag.documentation: \
This draws a waving colored flag, that undulates its way around the \
screen. The trick is the flag can contain arbitrary text and images. \
By default, it displays either the current system name and OS \
type, or a picture of ``Bob,'' but you can replace the text or the \
image with a command-line option. Written by Charles Vidal and Jamie \
Zawinski.",
"*hacks.sphere.documentation: \
Another of the classic screenhacks of the distant past, this one \
draws shaded spheres in multiple colors. This hack traces its \
lineage back to Tom Duff in 1982.",
"*hacks.forest.documentation: \
This draws fractal trees. Written by Peter Baumung. Everybody loves \
fractals, right?",
"*hacks.lisa.documentation: \
This draws Lisajous loops, by Caleb Cullen. Remember that device \
they had the Phantom Zone prisoners in during their trial in \
Superman? I think that was one of these.",
"*hacks.lissie.documentation: \
Another Lissajous figure. This one draws the progress of circular \
shapes along a path. Written by Alexander Jolk.",
"*hacks.goop.documentation: \
This draws set of animating, transparent, amoeba-like blobs. The \
blobs change shape as they wander around the screen, and they are \
translucent, so you can see the lower blobs through the higher ones, \
and when one passes over another, their colors merge. Written by \
Jamie Zawinski. I got the idea for this from a cool mouse pad I \
have, which achieves the same kind of effect in real life by having \
several layers plastic with colored oil between them. Written by \
Jamie Zawinski.",
"*hacks.starfish.documentation: \
This generates a sequence of undulating, throbbing, star-like \
patterns which pulsate, rotate, and turn inside out. Another display \
mode uses these shapes to lay down a field of colors, which are then \
cycled. The motion is very organic. Written by Jamie Zawinski.",
"*hacks.munch.documentation: \\n\
DATAI 2 \\n\
ADDB 1,2 \\n\
ROTC 2,-22 \\n\
XOR 1,2 \\n\
JRST .-4 \\n\
\\n\
As reported by HAKMEM, in 1962, Jackson Wright wrote the above PDP-1 \
code. That code still lives on in this screenhack, some 35 years \
later. The number of lines of enclosing code has increased \
substantially, however. This version is by Tim Showalter.",
"*hacks.fadeplot.name: FadePlot",
"*hacks.fadeplot.documentation: \
Draws what looks like a waving ribbon following a sinusoidal path. \
Written by Bas van Gaalen and Charles Vidal.",
"*hacks.coral.documentation: \
Simulates coral growth, albeit somewhat slowly. This image doesn't \
really do it justice. Written by Frederick Roeber.",
"*hacks.mountain.documentation: \
Generates random 3d plots that look vaguely mountainous. Written by \
Pascal Pensa.",
"*hacks.triangle.documentation: \
Generates random mountain ranges using iterative subdivision of \
triangles. Written by Tobias Gloth.",
"*hacks.worm.documentation: \
An ancient xlock hack that draws multicolored worms that crawl around \
the screen. Written by Brad Taylor, Dave Lemke, Boris Putanec, and \
Henrik Theiling.",
"*hacks.rotor.documentation: \
Another ancient xlock demo, this one by Tom Lawrence. It draws a \
line segment moving along a complex spiraling curve. I tweaked this \
to generate curvier lines, but still frames of it don't look like \
much.",
"*hacks.ant.documentation: \
A cellular automaton that is really a two-dimensional Turing machine: \
as the heads (``ants'') walk along the screen, they change pixel \
values in their path. Then, as they pass over changed pixels, their \
behavior is influenced. Written by David Bagley.",
"*hacks.demon.documentation: \
A cellular automaton that starts with a random field, and organizes \
it into stripes and spirals. Written by David Bagley.",
"*hacks.loop.documentation: \
This one produces loop-shaped colonies that spawn, age, and \
eventually die. Written by David Bagley.",
"*hacks.vines.documentation: \
This one generates a continuous sequence of small, curvy geometric \
patterns. It scatters them around your screen until it fills up, \
then it clears the screen and starts over. Written by Tracy Camp and \
David Hansen.",
"*hacks.kaleidescope.documentation: \
Another clone of an ancient meme, consisting largely of frenetic \
rotational motion of colored lines. This one is by Ron Tapia. The \
motion is nice, but I think it needs more solids, or perhaps just \
brighter colors. More variations in the rotational speed might help, \
too.",
"*hacks.xjack.documentation: \
This program behaves schizophrenically and makes a lot of typos. \
Written by Jamie Zawinski. If you haven't seen Stanley Kubrick's \
masterpiece, ``The Shining,'' you won't get it. Those who have \
describe this hack as ``inspired.''",
"*hacks.xlyap.documentation: \
This generates pretty fractal pictures by doing funky math involving \
the ``Lyapunov exponent.'' It has a cool interactive mode, too. \
Written by Ron Record.",
"*hacks.cynosure.documentation: \
A hack similar to `greynetic', but less frenetic. The first \
implementation was by Stephen Linhart; then Ozymandias G. Desiderata \
wrote a Java applet clone. That clone was discovered by Jamie \
Zawinski, and ported to C for inclusion here.",
"*hacks.flow.documentation: \
Another series of strange attractors: a flowing series of points, \
making strange rotational shapes. Written by Jeff Butterworth.",
"*hacks.epicycle.documentation: \
This program draws the path traced out by a point on the edge of a \
circle. That circle rotates around a point on the rim of another \
circle, and so on, several times. These were the basis for the \
pre-heliocentric model of planetary motion. Written by James \
Youngman.",
"*hacks.interference.documentation: \
Another color-field hack, this one works by computing decaying \
sinusoidal waves, and allowing them to interfere with each other as \
their origins move. Written by Hannu Mallat.",
"*hacks.truchet.documentation: \
This draws line- and arc-based Truchet patterns that tile the screen. \
Written by Adrian Likins.",
"*hacks.bsod.name: BSOD",
"*hacks.bsod.documentation: \
BSOD stands for ``Blue Screen of Death.'' The finest in personal \
computer emulation, this hack simulates popular screen savers from a \
number of less robust operating systems. Written by Jamie Zawinski.",
"*hacks.crystal.documentation: \
Moving polygons, similar to a kaleidescope (more like a kaleidescope \
than the hack called `kaleid,' actually.) This one by Jouk Jansen.",
"*hacks.discrete.documentation: \
More ``discrete map'' systems, including new variants of Hopalong and \
Julia, and a few others. Written by Tim Auckland.",
"*hacks.kumppa.documentation: \
Spiraling, spinning, and very, very fast splashes of color rush \
toward the screen. Written by Teemu Suutari.",
"*hacks.rd-bomb.name: RD-Bomb",
"*hacks.rd-bomb.documentation: \
Another variation of the `Bomb' program by Scott Draves. This draws \
a grid of growing square-like shapes that, once they overtake each \
other, react in unpredictable ways. ``RD'' stands for \
reaction-diffusion.",
"*hacks.sonar.documentation: \
This program draws a simulation of a sonar screen. Written by \
default, it displays a random assortment of ``bogies'' on the screen, \
but if compiled properly, it can ping (pun intended) your local \
network, and actually plot the proximity of the other hosts on your \
network to you. It would be easy to make it monitor other sources of \
data, too. (Processes? Active network connections? CPU usage per \
user?) Written by Stephen Martin.",
"*hacks.t3d.name: T3D",
"*hacks.t3d.documentation: \
This draws a working analog clock composed of floating, throbbing \
bubbles. Written by Bernd Paysan.",
"*hacks.penetrate.documentation: \
This hack simulates the classic arcade game Missile Command. Written \
by Adam Miller.",
"*hacks.deluxe.documentation: \
This draws a pulsing sequence of stars, circles, and lines. It would \
look better if it was faster, but as far as I can tell, there is no \
way to make this be both: fast, and flicker-free. Yet another reason \
X sucks. Written by Jamie Zawinski.",
"*hacks.compass.documentation: \
This draws a compass, with all elements spinning about randomly, for \
that ``lost and nauseous'' feeling. Written by Jamie Zawinski.",
"*hacks.squiral.documentation: \
Draws a set of interacting, square-spiral-producing automata. The \
spirals grow outward until they hit something, then they go around \
it. Written by Jeff Epler.",
"*hacks.xflame.documentation: \
Draws a simulation of pulsing fire. It can also take an arbitrary \
image and set it on fire too. Written by Carsten Haitzler, hacked on \
by many others.",
"*hacks.wander.documentation: \
Draws a colorful random-walk, in various forms. Written by Rick \
Campbell.",
"*hacks.critical.documentation: \
Draws a system of self-organizing lines. It starts out as random \
squiggles, but after a few iterations, order begins to appear. \
Written by Martin Pool.",
"*hacks.phosphor.documentation: \
Draws a simulation of an old terminal, with large pixels and \
long-sustain phosphor. It can run any program as a source of the text \
it displays. Written by Jamie Zawinski.",
"*hacks.xmatrix.documentation: \
A rendition of the text scrolls seen in the movie ``The Matrix.'' \
Written by Jamie Zawinski.",
"*hacks.petri.documentation: \
This simulates colonies of mold growing in a petri dish. Growing \
colored circles overlap and leave spiral interference in their wake. \
Written by Dan Bornstein.",
"*hacks.shadebobs.name: ShadeBobs",
"*hacks.shadebobs.documentation: \
This draws smoothly-shaded oscilating oval patterns, that look \
something like vapor trails or neon tubes. Written by Shane Smit.",
"*hacks.ccurve.name: C Curve",
"*hacks.ccurve.documentation: \
Generates self-similar linear fractals, including the classic ``C \
Curve.'' Written by Rick Campbell.",
"*hacks.blaster.documentation: \
Draws a simulation of flying space-combat robots (cleverly disguised \
as colored circles) doing battle in front of a moving star field. \
Written by Jonathan Lin.",
"*hacks.bumps.documentation: \
A bit like `Spotlight', except that instead of merely exposing part \
of your desktop, it creates a bump map from it. Basically, it \
3D-izes a roaming section of your desktop, based on color intensity. \
Written by Shane Smit.",
"*hacks.xteevee.name: XTeeVee",
"*hacks.xteevee.documentation: \
XTeeVee simulates various television problems, including static, \
loss of vertical hold, and a test pattern. By Greg Knauss.",
"*hacks.xspirograph.name: XSpiroGraph",
"*hacks.xspirograph.documentation: \
Simulates that pen-in-nested-plastic-gears toy from your childhood. \
By Rohit Singh.",
"*hacks.webcollage.name: WebCollage",
"*hacks.webcollage.documentation: \
This program makes collages out of random images pulled off of the \
World Wide Web. It finds these images by doing random web searches, \
and then extracting images from the returned pages. It can also be \
set up to filter the images through the `VidWhacker' program, above, \
which looks really great. \
\\n\\n\
(Note that most of the images it finds are text, and not pictures. \
This is because most of the web is pictures of text. Which is pretty \
sad.) Written by Jamie Zawinski.",
"*hacks.vidwhacker.name: VidWhacker",
"*hacks.vidwhacker.documentation: \
This is actually just a shell script that grabs a frame of video from \
the system's video input, and then uses some PBM filters (chosen at \
random) to manipulate and recombine the video frame in various ways \
(edge detection, subtracting the image from a rotated version of \
itself, etc.) Then it displays that image for a few seconds, and \
does it again. This works really well if you just feed broadcast \
television into it. \
\\n\\n\
Currently, the three lines of the script that actually grab the \
source picture are SGI specific, but it should be trivial to adapt it \
to work on other systems that can grab video (please send me the \
changes if you do this...)",
"*hacks.rocks.documentation: \
This draws an animation of flight through an asteroid field, with \
changes in rotation and direction. It can also display 3D \
separations for red/blue glasses! Mostly written by Jamie Zawinski.",
"*hacks.bubbles.documentation: \
This simulates the kind of bubble formation that happens when water \
boils:small bubbles appear, and as they get closer to each other, \
they combine to form larger bubbles, which eventually pop. Written \
by James Macnicol.",
"*hacks.gears.documentation: \
This draws a set of turning, interlocking gears, rotating in three \
dimensions. Another GL hack, by Danny Sung, Brian Paul, and Ed \
Mackey.",
"*hacks.superquadrics.documentation: \
Ed Mackey reports that he wrote the first version of this program in \
BASIC on a Commodore 64 in 1987, as a 320x200 black and white \
wireframe. Now it is GL and has specular reflections.",
"*hacks.morph3d.name: Morph3D",
"*hacks.morph3d.documentation: \
Another 3d shape-changing GL hack, by Marcelo Vianna. It has the \
same shiny-plastic feel as Superquadrics, as many computer-generated \
objects do...",
"*hacks.cage.documentation: \
This draws Escher's ``Impossible Cage,'' a 3d analog of a moebius \
strip, and rotates it in three dimensions. Written by Marcelo \
Vianna.",
"*hacks.moebius.documentation: \
Another M. C. Escher hack by Marcelo Vianna, this one draws \
``Moebius Strip II,'' a GL image of ants walking along the surface of \
a moebius strip.",
"*hacks.stairs.documentation: \
by Marcelo Vianna's third Escher GL hack, this one draws an \
``infinite'' staircase.",
"*hacks.pipes.documentation: \
If you've ever been in the same room with a Windows NT machine, \
you've probably seen this GL hack. This version is by Marcelo \
Vianna.",
"*hacks.sproingies.documentation: \
Q-Bert meets Marble Madness! Written by Ed Mackey.",
"*hacks.rubik.documentation: \
Draws a Rubik's Cube that rotates in three dimensions and repeatedly \
shuffles and solves itself. Another fine GL hack by Marcelo Vianna.",
"*hacks.atlantis.documentation: \
This is xfishtank writ large: a GL animation of a number of sharks, \
dolphins, and whales. The swimming motions are great. Originally \
written by Mark Kilgard.",
"*hacks.lament.documentation: \
Animates a simulation of Lemarchand's Box, repeatedly solving itself. \
Requires OpenGL, and a machine with fast hardware support for texture \
maps. Warning: occasionally opens doors. Written by Jamie Zawinski.",
"*hacks.bubble3d.name: Bubble3D",
"*hacks.bubble3d.documentation: \
Draws a stream of rising, undulating 3D bubbles, rising toward the \
top of the screen, with nice specular reflections. Written by Richard \
Jones.",
"*hacks.glplanet.name: GLPlanet",
"*hacks.glplanet.documentation: \
Draws a planet bouncing around in space. Written by David Konerding. \
The built-in image is a map of the earth (extracted from `xearth'), \
but you can wrap any texture around the sphere, e.g., the planetary \
textures that come with `ssystem'.",
"*hacks.pulsar.documentation: \
Draws some intersecting planes, making use of alpha blending, fog, \
textures, and mipmaps, plus a ``frames per second'' meter so that you \
can tell how fast your graphics card is... Requires OpenGL. Written \
by David Konerding.",
"*hacks.extrusion.documentation: \
Draws various rotating extruded shapes that twist around, lengthen, \
and turn inside out. Created by David Konerding from the samples \
that come with the GL Extrusion library by Linas Vepstas.",
"*hacks.sierpinski3d.name: Sierpinski3D",
"*hacks.sierpinski3d.documentation: \
This draws the three-dimensional variant of the recursive Sierpinski \
triangle fractal, using GL. Written by Tim Robinson and Jamie Zawinski.",
"*hacks.ripples.documentation: \
This draws rippling interference patterns like splashing water. \
With the -water option, it manipulates your desktop image to look \
like something is dripping into it. Written by Tom Hammersley.",
"*hacks.xdaliclock.name: XDaliClock",
"*hacks.xdaliclock.documentation: \
XDaliClock draws a large digital clock, the numbers of which change by \
``melting'' into their new shapes. Written by Jamie Zawinski. This \
is not included with the XScreenSaver package, but if you don't have \
it already, you can find it at <http://www.jwz.org/xdaliclock/>.",
"*hacks.xearth.documentation: \
XEarth draws an image of the Earth, as seen from your favorite vantage \
point in space, correctly shaded for the current position of the Sun. \
Written by Kirk Johnson. This is not included with the XScreenSaver \
package, but if you don't have it already, you can find it at \
<http://www.cs.colorado.edu/~tuna/xearth/>.",
"*hacks.ssystem.name: SSystem",
"*hacks.ssystem.documentation: \
SSystem is a GL Solar System simulator. It simulates flybys of Sun, \
the nine planets and a few major satellites, with four camera modes. \
Written by Raul Alonso. This is not included with the XScreenSaver \
package, but if you don't have it already, you can find it at \
<http://www1.las.es/~amil/ssystem/>.",
"*hacks.xmountains.documentation: \
XMountains generates realistic-looking fractal terrains of snow-capped \
mountains near water, with either a top view or a side view. \
Written by Stephen Booth. This is not included with the XScreenSaver \
package, but if you don't have it already, you can find it at \
<http://www.epcc.ed.ac.uk/~spb/xmountains/>. \
\\n\\n\
Be sure to compile it with -DVROOT or it won't work right when launched \
by the xscreensaver daemon.",
"*hacks.xaos.name: XaoS",
"*hacks.xaos.documentation: \
XaoS generates fast fly-through animations of the Mandelbrot and other \
fractal sets. Written by Thomas Marsh and Jan Hubicka. This is not \
included with the XScreenSaver package, but if you don't have it \
already, you can find it at <http://limax.paru.cas.cz/~hubicka/XaoS/>.",
"*hacks.xfishtank.name: XFishTank",
"*hacks.xfishtank.documentation: \
Fish! This is not included with the XScreenSaver package, but if you \
don't have it already, you can find it at \
<http://metalab.unc.edu/pub/Linux/X11/demos/>.",
"*hacks.xsnow.documentation: \
Draws falling snow and the occasional tiny Santa. By Rick Jansen. \
You can find it at <http://zoutmijn.bpa.nl/rick/Xsnow/>.",
"*hacks.goban.documentation: \
Replays historical games of go (aka wei-chi and baduk) on the screen. \
By Scott Draves. You can find it at <http://www.draves.org/goban/>.",
"*hacks.electricsheep.name: ElectricSheep",
"*hacks.electricsheep.documentation: \
ElectricSheep is an xscreensaver module that displays mpeg video of \
an animated fractal flame. In the background, it contributes render \
cycles to the next animation. Periodically it uploades completed \
frames to the server, where they are compressed for distribution to \
all clients. \
\\n\\n\
This program is recommended only if you have a high bandwidth \
connection to the Internet. \
\\n\\n\
By Scott Draves. You can find it at <http://www.electricsheep.org/>. \
See that web site for configuration information.",

View File

@@ -1,22 +0,0 @@
/* XPM */
static char * checked_disabled_xpm[] = {
"16 16 3 2",
" g None",
". g #000000",
"+ g #D9D9D9",
" ",
" ",
" . . . . . . . . . . . . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + . + . ",
" . + + + + + + + . . + . ",
" . + + + + + + . . . + . ",
" . + . + + + . . . + + . ",
" . + . . + . . . + + + . ",
" . + . . . . . + + + + . ",
" . + + . . . + + + + + . ",
" . + + + . + + + + + + . ",
" . + + + + + + + + + + . ",
" . . . . . . . . . . . . ",
" ",
" "};

View File

@@ -1,22 +0,0 @@
/* XPM */
static char * checked_xpm[] = {
"16 16 3 2",
" g None",
". g #000000",
"+ g #FFFFFF",
" ",
" ",
" . . . . . . . . . . . . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + . + . ",
" . + + + + + + + . . + . ",
" . + + + + + + . . . + . ",
" . + . + + + . . . + + . ",
" . + . . + . . . + + + . ",
" . + . . . . . + + + + . ",
" . + + . . . + + + + + . ",
" . + + + . + + + + + + . ",
" . + + + + + + + + + + . ",
" . . . . . . . . . . . . ",
" ",
" "};

View File

@@ -1,77 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* daemon.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <gnome.h>
#include "daemon.h"
void
start_xscreensaver (void)
{
gnome_execute_shell (".", "xscreensaver -no-splash &");
}
void
stop_xscreensaver (void)
{
gnome_execute_shell (".", "xscreensaver-command -exit");
}
void
restart_xscreensaver (void)
{
gnome_execute_shell (".", "xscreensaver-command -restart &");
}
void
setup_dpms (Preferences *prefs)
{
char *command_line;
guint standby_time, suspend_time, power_down_time;
if (!prefs->power_management) return;
standby_time = prefs->standby_time ?
(prefs->timeout + prefs->standby_time) * 60 : 0;
suspend_time = prefs->suspend_time ?
(prefs->timeout + prefs->suspend_time) * 60 : 0;
power_down_time = prefs->power_down_time ?
(prefs->timeout + prefs->power_down_time) * 60 : 0;
/* Sanitize values */
if (standby_time > suspend_time) standby_time = 0;
if (standby_time > power_down_time) standby_time = 0;
if (suspend_time > power_down_time) suspend_time = 0;
command_line = g_strdup_printf ("xset dpms %u %u %u",
standby_time,
suspend_time,
power_down_time);
gnome_execute_shell (".", command_line);
g_free (command_line);
}

View File

@@ -1,34 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* daemon.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifndef __DAEMON_H
#define __DAEMON_H
#include "preferences.h"
void start_xscreensaver (void);
void stop_xscreensaver (void);
void restart_xscreensaver (void);
void setup_dpms (Preferences *prefs);
#endif /* __DAEMON_H */

View File

@@ -1,259 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* expr.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "expr.h"
static gdouble int_parse_sentence (GScanner *scanner);
static gdouble int_parse_unary (GScanner *scanner);
static gdouble int_parse_atom (GScanner *scanner);
static gdouble int_parse_expr (GScanner *scanner, gboolean expr,
gboolean neg);
static gdouble int_parse_term (GScanner *scanner, gboolean expr,
gboolean inv);
static gdouble int_parse_factor (GScanner *scanner, gboolean expr);
gboolean
parse_sentence (gchar *sentence, GScanner *scanner)
{
g_scanner_input_text (scanner, sentence, strlen (sentence));
g_scanner_get_next_token (scanner);
return int_parse_sentence (scanner) != 0.0;
}
gdouble
parse_expr (gchar *expr, gdouble var)
{
static GScannerConfig config;
GScanner *scanner;
gchar *var_string;
gfloat ret;
config.cset_skip_characters = " \t\n";
config.cset_identifier_first = "abcdefghijklmnopqrstuvwxyz";
config.cset_identifier_nth = "abcdefghijklmnopqrstuvwxyz_";
config.scan_symbols = TRUE;
config.scan_identifier = TRUE;
scanner = g_scanner_new (&config);
g_scanner_input_text (scanner, expr, strlen (expr));
g_scanner_get_next_token (scanner);
g_scanner_set_scope (scanner, 0);
var_string = g_strdup_printf ("%f", var);
g_scanner_scope_add_symbol (scanner, 0, "var", var_string);
ret = int_parse_expr (scanner, TRUE, FALSE);
g_free (var_string);
g_scanner_destroy (scanner);
return ret;
}
static gdouble
int_parse_sentence (GScanner *scanner)
{
GTokenType token_type;
GTokenValue value;
gdouble left;
left = int_parse_unary (scanner);
token_type = g_scanner_cur_token (scanner);
value = g_scanner_cur_value (scanner);
if ((token_type == G_TOKEN_CHAR && value.v_char == '&') ||
(token_type == G_TOKEN_SYMBOL && value.v_symbol == SYMBOL_AND))
{
g_scanner_get_next_token (scanner);
return (int_parse_sentence (scanner) != 0.0 &&
left != 0.0) ? 1.0 : 0.0;
}
else if ((token_type == G_TOKEN_CHAR && value.v_char == '|') ||
(token_type == G_TOKEN_SYMBOL &&
value.v_symbol == SYMBOL_OR))
{
g_scanner_get_next_token (scanner);
return (int_parse_sentence (scanner) != 0.0 ||
left != 0.0) ? 1.0 : 0.0;
}
return left;
}
static gdouble
int_parse_unary (GScanner *scanner)
{
GTokenType token_type;
GTokenValue value;
token_type = g_scanner_cur_token (scanner);
value = g_scanner_cur_value (scanner);
if ((token_type == G_TOKEN_CHAR && value.v_char == '!') ||
(token_type == G_TOKEN_SYMBOL && value.v_symbol == SYMBOL_NOT))
{
g_scanner_get_next_token (scanner);
return (int_parse_unary (scanner) != 0.0) ? 0.0 : 1.0;
} else {
return (int_parse_atom (scanner) != 0.0) ? 1.0 : 0.0;
}
}
static gdouble
int_parse_atom (GScanner *scanner)
{
GTokenType token_type;
GTokenValue value;
gdouble left;
left = int_parse_expr (scanner, FALSE, FALSE);
token_type = g_scanner_cur_token (scanner);
if (token_type == G_TOKEN_CHAR) {
value = g_scanner_cur_value (scanner);
if (value.v_char == '=') {
g_scanner_get_next_token (scanner);
return (int_parse_expr (scanner, FALSE, FALSE)
== left) ? 1.0 : 0.0;
}
else if (value.v_char == '<') {
g_scanner_get_next_token (scanner);
return (int_parse_expr (scanner, FALSE, FALSE)
> left) ? 1.0 : 0.0;
}
else if (value.v_char == '>') {
g_scanner_get_next_token (scanner);
return (int_parse_expr (scanner, FALSE, FALSE)
< left) ? 1.0 : 0.0;
}
}
return left;
}
static gdouble
int_parse_expr (GScanner *scanner, gboolean expr, gboolean neg)
{
GTokenType token_type;
GTokenValue value;
gdouble left;
gdouble ret;
left = int_parse_term (scanner, expr, FALSE);
token_type = g_scanner_cur_token (scanner);
if (token_type == G_TOKEN_CHAR) {
value = g_scanner_cur_value (scanner);
if (value.v_char == '+') {
g_scanner_get_next_token (scanner);
return left + int_parse_expr (scanner, expr, FALSE);
}
else if (value.v_char == '-') {
g_scanner_get_next_token (scanner);
ret = int_parse_expr (scanner, expr, TRUE);
if (neg)
return left + ret;
else
return left - ret;
}
}
return left;
}
static gdouble
int_parse_term (GScanner *scanner, gboolean expr, gboolean inv)
{
GTokenType token_type;
GTokenValue value;
gdouble left;
gdouble ret;
left = int_parse_factor (scanner, expr);
token_type = g_scanner_cur_token (scanner);
if (token_type == G_TOKEN_CHAR) {
value = g_scanner_cur_value (scanner);
if (token_type == '*') {
g_scanner_get_next_token (scanner);
return left * int_parse_term (scanner, expr, FALSE);
}
else if (token_type == '/') {
g_scanner_get_next_token (scanner);
ret = int_parse_term (scanner, expr, TRUE);
if (inv)
return left * ret;
else
return left / ret;
}
}
return left;
}
static gdouble
int_parse_factor (GScanner *scanner, gboolean expr)
{
GTokenType token_type;
GTokenValue value;
gdouble ret;
token_type = g_scanner_cur_token (scanner);
value = g_scanner_cur_value (scanner);
g_scanner_get_next_token (scanner);
if (token_type == G_TOKEN_CHAR && value.v_char == '(') {
if (expr)
ret = int_parse_expr (scanner, TRUE, FALSE);
else
ret = int_parse_sentence (scanner);
g_scanner_get_next_token (scanner);
return ret;
}
else if (token_type == G_TOKEN_INT) {
return value.v_int;
}
else if (token_type == G_TOKEN_FLOAT) {
return value.v_float;
}
else if (token_type == G_TOKEN_SYMBOL) {
if (value.v_symbol == (gpointer) 1)
return (gint) value.v_symbol;
else
return g_strtod (value.v_symbol, NULL);
}
else if (token_type == G_TOKEN_IDENTIFIER) {
return 0.0;
} else {
g_scanner_error (scanner, "Parse error in expression");
}
return 0;
}

View File

@@ -1,36 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* expr.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifndef __EXPR_H
#define __EXPR_H
#include <glib.h>
#define SYMBOL_AND ((gpointer) -1)
#define SYMBOL_OR ((gpointer) -2)
#define SYMBOL_NOT ((gpointer) -3)
gboolean parse_sentence (gchar *sentence, GScanner *scanner);
gdouble parse_expr (gchar *expr, gdouble var);
#endif /* __EXPR_H */

View File

@@ -1,248 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* main.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include <gnome.h>
#include <libgnomeui/gnome-window-icon.h>
#include <glade/glade.h>
#include <capplet-widget.h>
#include "preferences.h"
#include "prefs-widget.h"
#include "preview.h"
#include "daemon.h"
#include "resources.h"
static Preferences *prefs;
static Preferences *old_prefs;
static PrefsWidget *prefs_widget;
static CappletWidget *capplet;
static void
state_changed_cb (GtkWidget *widget)
{
if (!prefs->frozen)
capplet_widget_state_changed (capplet, TRUE);
}
static void
try_cb (GtkWidget *widget)
{
gboolean old_sm;
old_sm = prefs->selection_mode;
prefs_widget_store_prefs (prefs_widget, prefs);
preferences_save (prefs);
setup_dpms (prefs);
if (old_sm == SM_DISABLE_SCREENSAVER &&
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
start_xscreensaver ();
else if (old_sm != SM_DISABLE_SCREENSAVER &&
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
stop_xscreensaver ();
}
static void
revert_cb (GtkWidget *widget)
{
gboolean old_sm;
old_sm = old_prefs->selection_mode;
preferences_save (old_prefs);
preferences_destroy (prefs);
prefs = preferences_new ();
preferences_load (prefs);
prefs->frozen = TRUE;
prefs_widget_get_prefs (prefs_widget, prefs);
prefs->frozen = FALSE;
setup_dpms (old_prefs);
if (old_sm == SM_DISABLE_SCREENSAVER &&
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
start_xscreensaver ();
else if (old_sm != SM_DISABLE_SCREENSAVER &&
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
stop_xscreensaver ();
}
static void
ok_cb (GtkWidget *widget)
{
gboolean old_sm;
old_sm = prefs->selection_mode;
close_preview ();
prefs_widget_store_prefs (prefs_widget, prefs);
preferences_save (prefs);
setup_dpms (prefs);
if (old_sm == SM_DISABLE_SCREENSAVER &&
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
start_xscreensaver ();
else if (old_sm != SM_DISABLE_SCREENSAVER &&
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
stop_xscreensaver ();
}
static void
cancel_cb (GtkWidget *widget)
{
gboolean old_sm;
old_sm = old_prefs->selection_mode;
close_preview ();
preferences_save (old_prefs);
setup_dpms (old_prefs);
if (old_sm == SM_DISABLE_SCREENSAVER &&
prefs->selection_mode != SM_DISABLE_SCREENSAVER)
start_xscreensaver ();
else if (old_sm != SM_DISABLE_SCREENSAVER &&
prefs->selection_mode == SM_DISABLE_SCREENSAVER)
stop_xscreensaver ();
}
static void
demo_cb (GtkWidget *widget)
{
prefs->screensavers = prefs_widget->screensavers;
preferences_save (prefs);
}
static void
setup_capplet_widget (void)
{
capplet = CAPPLET_WIDGET (capplet_widget_new ());
gtk_signal_connect (GTK_OBJECT (capplet), "try",
GTK_SIGNAL_FUNC (try_cb), NULL);
gtk_signal_connect (GTK_OBJECT (capplet), "revert",
GTK_SIGNAL_FUNC (revert_cb), NULL);
gtk_signal_connect (GTK_OBJECT (capplet), "ok",
GTK_SIGNAL_FUNC (ok_cb), NULL);
gtk_signal_connect (GTK_OBJECT (capplet), "cancel",
GTK_SIGNAL_FUNC (cancel_cb), NULL);
prefs->frozen = TRUE;
prefs_widget = PREFS_WIDGET (prefs_widget_new ());
gtk_container_add (GTK_CONTAINER (capplet), GTK_WIDGET (prefs_widget));
set_preview_window (PREFS_WIDGET (prefs_widget)->preview_window);
prefs_widget_get_prefs (prefs_widget, prefs);
gtk_signal_connect (GTK_OBJECT (prefs_widget), "pref-changed",
GTK_SIGNAL_FUNC (state_changed_cb), NULL);
gtk_signal_connect (GTK_OBJECT (prefs_widget), "activate-demo",
GTK_SIGNAL_FUNC (demo_cb), NULL);
gtk_widget_show_all (GTK_WIDGET (capplet));
prefs->frozen = FALSE;
}
int
main (int argc, char **argv)
{
GnomeClient *client;
GnomeClientFlags flags;
gint token, res;
gchar *restart_args[3];
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
glade_gnome_init ();
res = gnome_capplet_init ("screensaver-properties",
VERSION, argc, argv, NULL,
0, NULL);
if (res < 0) {
g_error ("Could not initialize the capplet.");
}
client = gnome_master_client ();
flags = gnome_client_get_flags (client);
if (flags & GNOME_CLIENT_IS_CONNECTED) {
token = gnome_startup_acquire_token
("GNOME_SCREENSAVER_PROPERTIES",
gnome_client_get_id (client));
if (token) {
gnome_client_set_priority (client, 20);
gnome_client_set_restart_style (client,
GNOME_RESTART_ANYWAY);
restart_args[0] = argv[0];
restart_args[1] = "--init-session-settings";
restart_args[2] = NULL;
gnome_client_set_restart_command (client, 2,
restart_args);
} else {
gnome_client_set_restart_style (client,
GNOME_RESTART_NEVER);
}
} else {
token = 1;
}
gnome_window_icon_set_default_from_file
(GNOME_ICONDIR"/gnome-ccscreensaver.png");
init_resource_database (argc, argv);
prefs = preferences_new (); preferences_load (prefs);
if (token) {
if (prefs->selection_mode != SM_DISABLE_SCREENSAVER)
start_xscreensaver ();
setup_dpms (prefs);
}
if (!res) {
old_prefs = preferences_new (); preferences_load (old_prefs);
setup_capplet_widget ();
capplet_gtk_main ();
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -1,538 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* pref-file.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <unistd.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <pwd.h>
#include <errno.h>
#include <gnome.h>
#include "pref-file.h"
#include "rc-parse.h"
#define START_BUF_SIZE 1024
#define MIN_FREE_BUF 128
/* From xscreensaver 3.24 driver/prefs.c line 80 ... */
static char *
chase_symlinks (const char *file)
{
# ifdef HAVE_REALPATH
char buf[2048], *msg;
if (file) {
if (realpath (file, buf))
return g_strdup (buf);
msg = g_strdup_printf ("realpath: %s", g_strerror (errno));
g_warning (msg);
}
# endif /* HAVE_REALPATH */
return 0;
}
static const char *
init_file_name (void)
{
static char *file = 0;
if (!file)
file = g_concat_dir_and_file (g_get_home_dir (),
".xscreensaver");
if (file && *file)
return file;
else
return NULL;
}
static const char *
init_file_tmp_name (void)
{
static char *file = 0;
if (!file)
{
const char *name = init_file_name();
const char *suffix = ".tmp";
char *n2 = chase_symlinks (name);
if (n2) name = n2;
if (!name || !*name)
file = "";
else
file = g_strconcat (name, suffix, NULL);
if (n2) g_free (n2);
}
if (file && *file)
return file;
else
return 0;
}
/* From xscreensaver 3.24 driver/prefs.c line 211 ... */
static char *
get_line (FILE *file, int *line_no)
{
char *buf, *start;
int buf_size = START_BUF_SIZE, free_buf = START_BUF_SIZE;
int len, l;
buf = start = g_new (char, buf_size);
(*line_no)++;
if (!fgets (start, buf_size, file)) {
g_free (start);
return NULL;
}
len = strlen (start);
while (buf[len-1] != '\n' || buf[len-2] == '\\') {
free_buf -= len;
buf += len;
if (free_buf < MIN_FREE_BUF) {
free_buf += buf_size;
buf_size *= 2;
l = buf - start;
start = g_renew (char, start, buf_size);
buf = start + l;
}
if (buf[-2] == '\\') (*line_no)++;
if (!fgets (buf, free_buf - 1, file))
return start;
len = strlen (buf);
}
return start;
}
static char *
transform_line (char *line)
{
char *line1;
int i, i1 = 0, len;
len = strlen (line);
line1 = g_new (char, len + 1);
for (i = 0; i <= len; i++) {
if (line[i] != '\\') {
line1[i1++] = line[i];
} else {
i++;
switch (line[i]) {
case 'n':
line1[i1++] = '\n';
break;
case 'r':
line1[i1++] = '\r';
break;
case 't':
line1[i1++] = '\t';
break;
case '\\':
line1[i1++] = '\\';
break;
case '\n':
break;
default:
line1[i1++] = line[i];
break;
}
}
}
return line1;
}
/* Adapted from xscreensaver 3.24 driver/prefs.c line 257 ... */
static GTree *
parse_config_file (const char *file_name)
{
struct stat st;
FILE *in;
char *buf;
GTree *config_db;
gint line_no;
char *line, *key, *value;
if (!g_file_test (file_name, G_FILE_TEST_ISFILE))
return NULL;
in = fopen (file_name, "r");
if (!in) {
g_warning ("error reading \"%s\": %s",
file_name, g_strerror (errno));
return NULL;
}
if (fstat (fileno(in), &st) != 0) {
g_warning ("couldn't re-stat \"%s\": %s",
file_name, g_strerror (errno));
return NULL;
}
config_db = g_tree_new ((GCompareFunc) strcmp);
line_no = 0;
while ((buf = get_line (in, &line_no))) {
line = transform_line (buf); g_free (buf);
key = g_strstrip (line);
if (*key == '#' || *key == '!' || *key == ';' ||
*key == '\n' || *key == 0)
continue;
value = strchr (key, ':');
if (!value) {
g_warning("%s:%d: unparsable line: %s\n",
file_name, line_no, key);
continue;
} else {
*value++ = 0;
value = g_strstrip (value);
}
g_tree_insert (config_db, g_strdup (key), g_strdup (value));
}
fclose (in);
return config_db;
}
gboolean
preferences_load_from_file (Preferences *prefs)
{
prefs->config_db = parse_config_file (init_file_name ());
if (!prefs->config_db)
return FALSE;
else
return TRUE;
}
/* Writing
*/
/* From xscreensaver 3.24 driver/prefs.c line 168 ... */
static const char * const pref_names[] = {
"timeout",
"cycle",
"lock",
"lockVTs",
"lockTimeout",
"passwdTimeout",
"visualID",
"installColormap",
"verbose",
"timestamp",
"splashDuration",
"demoCommand",
"prefsCommand",
"helpURL",
"loadURL",
"nice",
"fade",
"unfade",
"fadeSeconds",
"fadeTicks",
"captureStderr",
"font",
"",
"programs",
"",
"pointerPollTime",
"windowCreationTimeout",
"initialDelay",
"sgiSaverExtension",
"mitSaverExtension",
"xidleExtension",
"procInterrupts",
"overlayStderr",
0
};
/* From xscreensaver 3.24 driver/prefs.c line 397 ... */
static int
tab_to (FILE *out, int from, int to)
{
int tab_width = 8;
int to_mod = (to / tab_width) * tab_width;
while (from < to_mod) {
fprintf(out, "\t");
from = (((from / tab_width) + 1) * tab_width);
}
while (from < to) {
fprintf(out, " ");
from++;
}
return from;
}
/* From xscreensaver 3.24 driver/prefs.c line 453 ... */
static void
write_entry (FILE *out, const char *key, const char *value)
{
char *v = g_strdup(value ? value : "");
char *v2 = v;
char *nl = 0;
int col;
gboolean programs_p = (!strcmp(key, "programs"));
int tab = (programs_p ? 32 : 16);
gboolean first = TRUE;
fprintf (out, "%s:", key);
col = strlen(key) + 1;
while (1) {
if (!programs_p)
v2 = g_strstrip(v2);
nl = strchr(v2, '\n');
if (nl)
*nl = 0;
if (first && programs_p) {
col = tab_to (out, col, 77);
fprintf (out, " \\\n");
col = 0;
}
if (first)
first = FALSE;
else {
col = tab_to (out, col, 75);
fprintf (out, " \\n\\\n");
col = 0;
}
if (!programs_p)
col = tab_to (out, col, tab);
if (programs_p &&
string_columns(v2, strlen (v2), col) + col > 75)
{
int L = strlen (v2);
int start = 0;
int end = start;
while (start < L) {
while (v2[end] == ' ' || v2[end] == '\t')
end++;
while (v2[end] != ' ' && v2[end] != '\t' &&
v2[end] != '\n' && v2[end] != 0)
end++;
if (string_columns (v2 + start,
(end - start), col) >= 74)
{
col = tab_to (out, col, 75);
fprintf(out, " \\\n");
col = tab_to (out, 0, tab + 2);
while (v2[start] == ' ' ||
v2[start] == '\t')
start++;
}
col = string_columns (v2 + start,
(end - start), col);
while (start < end)
fputc(v2[start++], out);
}
} else {
fprintf (out, "%s", v2);
col += string_columns(v2, strlen (v2), col);
}
if (nl)
v2 = nl + 1;
else
break;
}
fprintf(out, "\n");
g_free(v);
}
static int
write_preference_cb (gchar *key, gchar *value, FILE *out)
{
write_entry (out, key, value);
return FALSE;
}
/* Adapted from xscreensaver 3.24 driver/prefs.c line 537 ... */
gint
preferences_save_to_file (Preferences *prefs)
{
int status = -1;
const char *name = init_file_name();
const char *tmp_name = init_file_tmp_name();
char *n2 = chase_symlinks (name);
struct stat st;
FILE *out;
if (!name) goto END;
if (n2) name = n2;
if (prefs->verbose)
g_message ("writing \"%s\".\n", name);
unlink (tmp_name);
out = fopen(tmp_name, "w");
if (!out)
{
g_warning ("error writing \"%s\": %s", name,
g_strerror (errno));
goto END;
}
/* Give the new .xscreensaver file the same permissions as the old one;
except ensure that it is readable and writable by owner, and not
executable. Extra hack: if we're running as root, make the file
be world-readable (so that the daemon, running as "nobody", will
still be able to read it.)
*/
if (g_file_test (name, G_FILE_TEST_ISFILE)) {
mode_t mode = st.st_mode;
mode |= S_IRUSR | S_IWUSR; /* read/write by user */
mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH); /* executable by none */
if (getuid() == (uid_t) 0) /* read by group/other */
mode |= S_IRGRP | S_IROTH;
if (fchmod (fileno(out), mode) != 0)
{
g_warning ("error fchmodding \"%s\" to 0%o: %s",
tmp_name, (guint) mode, g_strerror (errno));
goto END;
}
}
{
struct passwd *pw = getpwuid (getuid ());
char *whoami = (pw && pw->pw_name && *pw->pw_name
? pw->pw_name
: "<unknown>");
time_t now = time ((time_t *) 0);
char *timestr = (char *) ctime (&now);
char *nl = (char *) strchr (timestr, '\n');
if (nl) *nl = 0;
fprintf (out,
"# %s Preferences File\n"
"# Written by %s %s for %s on %s.\n"
"# http://www.jwz.org/xscreensaver/\n"
"\n",
"XScreenSaver", "xscreensaver", "3.24", whoami, timestr);
}
g_tree_traverse (prefs->config_db,
(GTraverseFunc) write_preference_cb,
G_IN_ORDER, out);
fprintf(out, "\n");
if (fclose(out) == 0)
{
time_t write_date = 0;
if (stat (tmp_name, &st) == 0)
{
write_date = st.st_mtime;
}
else
{
g_warning ("couldn't stat \"%s\": %s",
tmp_name, g_strerror (errno));
unlink (tmp_name);
goto END;
}
if (rename (tmp_name, name) != 0) {
g_warning ("error renaming \"%s\" to \"%s\": %s",
tmp_name, name, g_strerror (errno));
unlink (tmp_name);
goto END;
} else {
prefs->init_file_date = write_date;
/* Since the .xscreensaver file is used for
* IPC, let's try and make sure that the bits
* actually land on the disk right away.
*/
sync ();
status = 0; /* wrote and renamed successfully! */
}
}
else
{
g_warning ("error closing \"%s\": %s",
name, g_strerror (errno));
unlink (tmp_name);
goto END;
}
END:
if (n2) g_free (n2);
return status;
}

View File

@@ -1,33 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* pref-file.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifndef __PREF_FILE_H
#define __PREF_FILE_H
#include "preferences.h"
gboolean preferences_load_from_file (Preferences *prefs);
gint preferences_save_to_file (Preferences *prefs);
#endif /* __PREF_FILE_H */

View File

@@ -1,288 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* preferences.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <gnome.h>
#include "preferences.h"
#include "preview.h"
#include "pref-file.h"
#include "resources.h"
#include "rc-parse.h"
static void
remove_entry (GTree *config_db, gchar *entry)
{
gchar *value_str;
value_str = g_tree_lookup (config_db, "verbose");
g_tree_remove (config_db, "verbose");
if (value_str) g_free (value_str);
}
static void
read_prefs_from_db (Preferences *prefs)
{
gchar *value;
value = g_tree_lookup (prefs->config_db, "verbose");
if (value) prefs->verbose = parse_boolean_resource (value);
value = g_tree_lookup (prefs->config_db, "lock");
if (value) prefs->lock = parse_boolean_resource (value);
value = g_tree_lookup (prefs->config_db, "fade");
if (value) prefs->fade = parse_boolean_resource (value);
value = g_tree_lookup (prefs->config_db, "unfade");
if (value) prefs->unfade = parse_boolean_resource (value);
value = g_tree_lookup (prefs->config_db, "fadeSeconds");
if (value) prefs->fade_seconds = parse_seconds_resource (value);
value = g_tree_lookup (prefs->config_db, "fadeTicks");
if (value) prefs->fade_ticks = parse_integer_resource (value);
value = g_tree_lookup (prefs->config_db, "installColormap");
if (value) prefs->install_colormap = parse_boolean_resource (value);
value = g_tree_lookup (prefs->config_db, "nice");
if (value) prefs->nice = parse_integer_resource (value);
value = g_tree_lookup (prefs->config_db, "timeout");
if (value) prefs->timeout = parse_minutes_resource (value);
value = g_tree_lookup (prefs->config_db, "lockTimeout");
if (value) prefs->lock_timeout = parse_minutes_resource (value);
value = g_tree_lookup (prefs->config_db, "cycle");
if (value) prefs->cycle = parse_minutes_resource (value);
value = g_tree_lookup (prefs->config_db, "programs");
if (value) prefs->screensavers = parse_screensaver_list (value);
}
static void
store_prefs_in_db (Preferences *prefs)
{
remove_entry (prefs->config_db, "verbose");
g_tree_insert (prefs->config_db, "verbose",
write_boolean (prefs->verbose));
remove_entry (prefs->config_db, "lock");
g_tree_insert (prefs->config_db, "lock",
write_boolean (prefs->lock));
remove_entry (prefs->config_db, "fade");
g_tree_insert (prefs->config_db, "fade",
write_boolean (prefs->fade));
remove_entry (prefs->config_db, "unfade");
g_tree_insert (prefs->config_db, "unfade",
write_boolean (prefs->unfade));
remove_entry (prefs->config_db, "fadeSeconds");
g_tree_insert (prefs->config_db, "fadeSeconds",
write_seconds (prefs->fade_seconds));
remove_entry (prefs->config_db, "fadeTicks");
g_tree_insert (prefs->config_db, "fadeTicks",
write_integer (prefs->fade_ticks));
remove_entry (prefs->config_db, "installColormap");
g_tree_insert (prefs->config_db, "installColormap",
write_boolean (prefs->install_colormap));
remove_entry (prefs->config_db, "nice");
g_tree_insert (prefs->config_db, "nice",
write_integer (prefs->nice));
remove_entry (prefs->config_db, "timeout");
g_tree_insert (prefs->config_db, "timeout",
write_minutes (prefs->timeout));
remove_entry (prefs->config_db, "lockTimeout");
g_tree_insert (prefs->config_db, "lockTimeout",
write_minutes (prefs->lock_timeout));
remove_entry (prefs->config_db, "cycle");
g_tree_insert (prefs->config_db, "cycle",
write_minutes (prefs->cycle));
remove_entry (prefs->config_db, "programs");
g_tree_insert (prefs->config_db, "programs",
write_screensaver_list (prefs->screensavers));
}
Preferences *
preferences_new (void)
{
Preferences *prefs;
prefs = g_new0 (Preferences, 1);
return prefs;
}
void
preferences_destroy (Preferences *prefs)
{
GList *node;
if (!prefs) return;
/* Destroy screensavers */
if (prefs->screensavers) {
for (node = prefs->screensavers; node; node = node->next)
screensaver_destroy (SCREENSAVER (node->data));
g_list_free (prefs->screensavers);
}
if (prefs->programs_list) g_free (prefs->programs_list);
g_free (prefs);
}
void
preferences_load (Preferences *prefs)
{
g_return_if_fail (prefs != NULL);
if (!preferences_load_from_file (prefs))
preferences_load_from_xrdb (prefs);
read_prefs_from_db (prefs);
prefs->selection_mode =
gnome_config_get_int ("/Screensaver/Default/selection_mode=3");
prefs->power_management =
gnome_config_get_bool ("/Screensaver/Default/use_dpms=FALSE");
prefs->standby_time =
gnome_config_get_int ("/Screensaver/Default/standby_time=0");
prefs->suspend_time =
gnome_config_get_int ("/Screensaver/Default/suspend_time=0");
prefs->power_down_time =
gnome_config_get_int ("/Screensaver/Default/shutdown_time=20");
}
void
preferences_save (Preferences *prefs)
{
g_return_if_fail (prefs != NULL);
g_return_if_fail (prefs->config_db != NULL);
store_prefs_in_db (prefs);
preferences_save_to_file (prefs);
gnome_config_set_int ("/Screensaver/Default/selection_mode",
prefs->selection_mode);
gnome_config_set_bool ("/Screensaver/Default/use_dpms",
prefs->power_management);
gnome_config_set_int ("/Screensaver/Default/standby_time",
prefs->standby_time);
gnome_config_set_int ("/Screensaver/Default/suspend_time",
prefs->suspend_time);
gnome_config_set_int ("/Screensaver/Default/shutdown_time",
prefs->power_down_time);
gnome_config_sync ();
}
Screensaver *
screensaver_new (void)
{
Screensaver *saver;
saver = g_new0 (Screensaver, 1);
saver->name = NULL;
saver->enabled = TRUE;
return saver;
}
void
screensaver_destroy (Screensaver *saver)
{
if (!saver) return;
if (saver->visual) g_free (saver->visual);
if (saver->name) g_free (saver->name);
if (saver->command_line) g_free (saver->command_line);
if (saver->label) g_free (saver->label);
if (saver->description) g_free (saver->description);
g_free (saver);
}
GList *
screensaver_add (Screensaver *saver, GList *screensavers)
{
GList *list, *node;
g_return_val_if_fail (saver != NULL, NULL);
list = g_list_append (screensavers, saver);
saver->link = g_list_find (list, saver);
for (node = list; node != saver->link; node = node->next)
saver->id++;
return list;
}
GList *
screensaver_remove (Screensaver *saver, GList *screensavers)
{
GList *node;
g_return_val_if_fail (saver != NULL, NULL);
g_return_val_if_fail (saver->link != NULL, NULL);
g_return_val_if_fail (saver == saver->link->data, NULL);
for (node = saver->link->next; node; node = node->next)
SCREENSAVER (node->data)->id--;
return g_list_remove_link (screensavers, saver->link);
}
char *
screensaver_get_desc (Screensaver *saver)
{
g_return_val_if_fail (saver != NULL, NULL);
if (!saver->description)
screensaver_get_desc_from_xrdb (saver);
if (!saver->description)
saver->description = g_strdup (_("Custom screensaver. No description available"));
return saver->description;
}

View File

@@ -1,110 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* preferences.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifndef __PREFERENCES_H
#define __PREFERENCES_H
#include <sys/time.h>
#include <gtk/gtk.h>
enum _SelectionMode {
SM_DISABLE_SCREENSAVER,
SM_BLANK_SCREEN,
SM_ONE_SCREENSAVER_ONLY,
SM_CHOOSE_FROM_LIST,
SM_CHOOSE_RANDOMLY
};
typedef enum _SelectionMode SelectionMode;
#define SCREENSAVER(obj) ((Screensaver *) obj)
typedef struct _Screensaver Screensaver;
struct _Screensaver
{
guint id;
gchar *name;
gchar *label;
gchar *description;
gchar *command_line;
gchar *visual;
gboolean enabled;
GList *link;
};
struct _Preferences
{
time_t init_file_date;
gboolean verbose;
gboolean lock;
gboolean fade;
gboolean unfade;
time_t fade_seconds;
guint fade_ticks;
gboolean install_colormap;
gint nice;
gdouble timeout;
gdouble lock_timeout;
gdouble cycle;
gchar *programs_list; /* Programs resource, in JWZ's format */
SelectionMode selection_mode;
GList *screensavers;
gboolean frozen; /* TRUE if we shouldn't reflect
* preference changes in capplet */
GTree *config_db; /* key-value database of config options */
/* Settings that are not stored in .xscreensaver ... */
gboolean power_management;
time_t standby_time;
time_t suspend_time;
time_t power_down_time;
};
typedef struct _Preferences Preferences;
Preferences *preferences_new (void);
void preferences_destroy (Preferences *prefs);
void preferences_load (Preferences *prefs);
void preferences_save (Preferences *prefs);
Screensaver *screensaver_new (void);
void screensaver_destroy (Screensaver *saver);
GList *screensaver_add (Screensaver *saver, GList *screensavers);
GList *screensaver_remove (Screensaver *saver, GList *screensavers);
char *screensaver_get_desc (Screensaver *saver);
#endif /* __PREFERENCES_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,128 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* prefs-widget.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifndef __PREFS_WIDGET_H
#define __PREFS_WIDGET_H
#include <gtk/gtk.h>
#include "preferences.h"
#define PREFS_WIDGET(obj) GTK_CHECK_CAST (obj, prefs_widget_get_type (), PrefsWidget)
#define PREFS_WIDGET_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, prefs_widget_get_type (), PrefsWidgetClass)
#define IS_PREFS_WIDGET(obj) GTK_CHECK_TYPE (obj, prefs_widget_get_type ())
typedef struct _PrefsWidget PrefsWidget;
typedef struct _PrefsWidgetClass PrefsWidgetClass;
struct _PrefsWidget
{
GtkNotebook notebook;
GtkWidget *disable_screensaver_widget;
GtkWidget *blank_screen_widget;
GtkWidget *one_screensaver_widget;
GtkWidget *choose_from_list_widget;
GtkWidget *choose_randomly_widget;
GtkWidget *screensaver_list;
GtkWidget *demo_button;
GtkWidget *remove_button;
GtkWidget *settings_button;
GtkWidget *preview_window;
GtkWidget *description;
GtkObject *timeout_widget_adj;
GtkWidget *timeout_widget;
GtkObject *cycle_length_widget_adj;
GtkWidget *cycle_length_widget;
GtkWidget *lock_widget;
GtkWidget *enable_timeout_widget;
GtkObject *time_to_lock_widget_adj;
GtkWidget *time_to_lock_widget;
GtkWidget *lock_timeout_seconds_label;
GtkWidget *lock_vts_widget;
GtkWidget *pwr_manage_enable;
GtkWidget *standby_monitor_toggle;
GtkObject *standby_time_widget_adj;
GtkWidget *standby_time_widget;
GtkWidget *standby_monitor_label2;
GtkWidget *suspend_monitor_toggle;
GtkObject *suspend_time_widget_adj;
GtkWidget *suspend_time_widget;
GtkWidget *suspend_monitor_label2;
GtkWidget *shut_down_monitor_toggle;
GtkObject *shut_down_time_widget_adj;
GtkWidget *shut_down_time_widget;
GtkWidget *shut_down_monitor_label2;
GtkWidget *nice_widget;
GtkWidget *verbose_widget;
GtkWidget *effects_frame;
GtkWidget *install_cmap_widget;
GtkWidget *fade_widget;
GtkWidget *unfade_widget;
GtkWidget *fade_duration_label;
GtkWidget *fade_ticks_widget;
GtkWidget *fade_ticks_label;
GtkWidget *fade_duration_widget;
GtkWidget *fade_duration_high_label;
GtkWidget *fade_ticks_high_label;
GtkWidget *fade_duration_low_label;
GtkWidget *fade_ticks_low_label;
GList *screensavers;
Screensaver *selected_saver;
/* Cached preferences */
SelectionMode selection_mode;
};
struct _PrefsWidgetClass
{
GtkNotebookClass notebook_class;
void (*state_changed) (PrefsWidget *widget);
void (*activate_demo) (PrefsWidget *widget);
};
guint prefs_widget_get_type (void);
GtkWidget *prefs_widget_new (void);
void prefs_widget_get_prefs (PrefsWidget *prefs_widget,
Preferences *prefs);
void prefs_widget_store_prefs (PrefsWidget *prefs_widget,
Preferences *prefs);
void prefs_widget_set_screensavers (PrefsWidget *prefs_widget,
GList *screensavers,
SelectionMode mode);
#endif /* __PREFS_WIDGET_H */

View File

@@ -1,322 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* preview.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <sys/wait.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gnome.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <X11/Xatom.h>
#include "preview.h"
static GtkWidget *preview_window;
static pid_t preview_pid;
static int timeout_id;
#if 0
/* DEBUG FUNCTION */
static void
print_args (char **args)
{
int i;
printf ("Command line:\n");
for (i = 0; args[i]; i++) {
printf ("%s ", args[i]);
}
printf ("\n");
}
#endif
void
set_preview_window (GtkWidget *widget)
{
preview_window = widget;
}
static char **
strip_arg (char **args, char *arg)
{
int i, j, arg_len;
arg_len = strlen (arg);
for (i = 0; args[i]; i++) {
if (!strncmp (args[i], arg, arg_len)) {
for (j = i; args[j]; j++)
args[j] = args[j + 1];
i--;
}
}
return args;
}
static void
setup_path (void)
{
char *path, *newpath;
path = getenv ("PATH");
newpath = g_strconcat (path, ":/usr/X11R6/lib/xscreensaver", NULL);
setenv ("PATH", newpath, TRUE);
}
/* Warning: memory leaks, please do not use except in a separate
* process
*/
static char **
add_window_arg (char **args, GdkWindow *window)
{
int i;
char *x_window_id;
for (i = 0; args[i]; i++);
x_window_id =
g_strdup_printf ("0x%x",
(guint) GDK_WINDOW_XWINDOW (window));
args = g_renew (char *, args, i + 4);
args[i] = "-window";
args[i + 1] = "-window-id";
args[i + 2] = x_window_id;
args[i + 3] = NULL;
return args;
}
/* show_screensaver
*
* Given a GdkWindow in which to render and a particular screensaver,
* fork off a process and start the screensaver.
*/
static void
show_screensaver (GdkWindow *window, Screensaver *saver, pid_t *pid)
{
char **args;
*pid = fork ();
if (*pid == (pid_t) -1) {
perror ("fork");
abort ();
}
else if (*pid == 0) {
nice (20); /* Very low priority */
args = g_strsplit (saver->command_line, " ", -1);
args = strip_arg (args, "-root");
args = add_window_arg (args, window);
setup_path ();
if (execvp (args[0], args) == -1) {
perror ("execv");
abort ();
}
exit (1);
}
}
static gint
show_screensaver_timeout (void)
{
GdkPixbuf *pixbuf;
int ret;
ret = waitpid (preview_pid, NULL, WNOHANG);
if (ret == -1) {
g_error ("waitpid: %s", g_strerror (errno));
}
else if (ret > 0) {
pixbuf = gdk_pixbuf_new_from_file
(GNOME_ICONDIR "/no-hack.png");
gdk_pixbuf_render_to_drawable
(pixbuf, (GdkDrawable *) preview_window->window,
preview_window->style->fg_gc[0], 0, 0, 0, 0,
300, 250, GDK_RGB_DITHER_NONE, 0, 0);
}
timeout_id = 0;
return FALSE;
}
void
show_preview (Screensaver *saver)
{
/* Note: kill this next line for a very interesting effect ... */
close_preview ();
if (!saver->command_line) return;
show_screensaver (preview_window->window, saver, &preview_pid);
timeout_id =
gtk_timeout_add (500, (GtkFunction)
show_screensaver_timeout, NULL);
}
void
close_preview (void)
{
if (timeout_id) {
gtk_timeout_remove (timeout_id);
timeout_id = 0;
}
if (preview_pid) {
kill (preview_pid, SIGTERM);
preview_pid = 0;
}
}
/* Ick... */
static GdkWindow *
gdk_window_new_from_xwindow (Window xwindow)
{
GdkWindow *window;
GdkWindowPrivate *window_priv;
window_priv = g_new0 (GdkWindowPrivate, 1);
window = (GdkWindow *) window_priv;
window_priv->xdisplay = gdk_display;
window_priv->xwindow = xwindow;
window_priv->destroyed = FALSE;
return window;
}
static GdkWindow *
find_xscreensaver_window (Display *dpy)
{
static Atom XA_SCREENSAVER;
GdkAtom actual_type;
gint actual_format;
Window root, parent, *children;
Window root_ret;
GdkWindow *ret;
gint number_children, i;
unsigned long nitems, bytes_after;
gboolean found;
unsigned char *data;
gint x_error;
if (!XA_SCREENSAVER)
XA_SCREENSAVER =
XInternAtom (dpy, "_SCREENSAVER_VERSION", FALSE);
gdk_error_trap_push ();
root = GDK_ROOT_WINDOW ();
XQueryTree (dpy, DefaultRootWindow (dpy),
&root_ret, &parent, &children, &number_children);
if (root_ret != root) abort ();
if (parent) abort ();
if (!children || !number_children) return NULL;
for (i = 0; i < number_children; i++) {
found = XGetWindowProperty (dpy, children[i],
XA_SCREENSAVER,
0, 0, FALSE, XA_STRING,
&actual_type,
&actual_format, &nitems,
&bytes_after, &data);
free (data);
if (actual_type != None) {
ret = gdk_window_new_from_xwindow (children[i]);
free (children);
return ret;
}
}
free (children);
gdk_flush ();
x_error = gdk_error_trap_pop ();
if (x_error && x_error != BadWindow)
g_error ("X error");
return NULL;
}
void
show_demo (Screensaver *saver)
{
static GdkAtom demo_atom, xscreensaver_atom;
GdkWindow *xscreensaver_window;
GdkEventClient *event;
if (!demo_atom)
demo_atom = gdk_atom_intern ("DEMO", FALSE);
if (!xscreensaver_atom)
xscreensaver_atom = gdk_atom_intern ("SCREENSAVER", FALSE);
xscreensaver_window = find_xscreensaver_window (gdk_display);
if (!xscreensaver_window)
g_error ("Could not find XScreensaver window");
event = g_new0 (GdkEventClient, 1);
event->type = GDK_CLIENT_EVENT;
event->window = xscreensaver_window;
event->message_type = xscreensaver_atom;
event->data_format = 32;
event->data.l[0] = demo_atom;
event->data.l[1] = 300; /* XA_DEMO protocol version number */
event->data.l[2] = saver->id + 1;
gdk_event_send_client_message
((GdkEvent *) event, GDK_WINDOW_XWINDOW (xscreensaver_window));
gdk_flush ();
g_free (xscreensaver_window);
g_free (event);
}
void
close_demo (void)
{
}

View File

@@ -1,39 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* preview.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifndef __PREVIEW_H
#define __PREVIEW_H
#include <gtk/gtk.h>
#include "preferences.h"
void set_preview_window (GtkWidget *widget);
void show_preview (Screensaver *saver);
void close_preview (void);
void show_demo (Screensaver *saver);
void close_demo (void);
#endif /* __PREVIEW_H */

View File

@@ -1,601 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* rc-parse.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <gnome.h>
#include "rc-parse.h"
#include "preferences.h"
#include "resources.h"
/* Adapted from xscreensaver 3.24 utils/resources.c line 57 ... */
gboolean
parse_boolean_resource (char *res)
{
if (!g_strncasecmp (res, "on", 2) ||
!g_strncasecmp (res, "true", 4) ||
!g_strncasecmp (res, "yes", 3))
return TRUE;
if (!g_strncasecmp (res, "off", 3) ||
!g_strncasecmp (res, "false", 5) ||
!g_strncasecmp (res, "no", 2))
return FALSE;
g_warning ("invalid boolean value: %s", res);
return FALSE;
}
int
parse_integer_resource (char *res)
{
int val;
char c;
while (*res && *res <= ' ') res++; /* skip whitespace */
if (res[0] == '0' && (res[1] == 'x' || res[1] == 'X')) {
if (sscanf (res + 2, "%x %c", &val, &c) == 1)
return val;
} else {
if (sscanf (res, "%d %c", &val, &c) == 1)
return val;
}
g_warning ("invalid integer value: %s", res);
return 0;
}
double
parse_float_resource (char *res)
{
double val;
char c;
if (sscanf (res, " %lf %c", &val, &c) == 1)
return val;
g_warning ("invalid float value: %s", res);
return 0.0;
}
static int
parse_time (const char *string, gboolean seconds_default_p, gboolean silent_p)
{
unsigned int h, m, s;
char c;
if (3 == sscanf (string, " %u : %2u : %2u %c", &h, &m, &s, &c))
;
else if (2 == sscanf (string, " : %2u : %2u %c", &m, &s, &c) ||
2 == sscanf (string, " %u : %2u %c", &m, &s, &c))
h = 0;
else if (1 == sscanf (string, " : %2u %c", &s, &c))
h = m = 0;
else if (1 == sscanf (string, " %u %c",
(seconds_default_p ? &s : &m), &c))
{
h = 0;
if (seconds_default_p) m = 0;
else s = 0;
} else {
if (! silent_p)
g_warning ("invalid time interval specification \"%s\".\n",
string);
return -1;
}
if (s >= 60 && (h != 0 || m != 0)) {
if (! silent_p)
g_warning ("seconds > 59 in \"%s\".\n", string);
return -1;
}
if (m >= 60 && h > 0) {
if (! silent_p)
g_warning ("minutes > 59 in \"%s\".\n", string);
return -1;
}
return ((h * 60 * 60) + (m * 60) + s);
}
guint
parse_time_resource (char *res, gboolean sec_p)
{
int val;
val = parse_time (res, sec_p, FALSE);
return (val < 0 ? 0 : val);
}
guint
parse_seconds_resource (char *res)
{
return parse_time_resource (res, TRUE);
}
gdouble
parse_minutes_resource (char *res)
{
return (gdouble) parse_time_resource (res, FALSE) / 60.0;
}
/*****************************************************************************/
/* Parsing the screensaver resource */
/*****************************************************************************/
/* Adapted from xscreensaver 3.24 driver/demo-Gtk.c line 944 ... */
static char *
get_settings_name (const char *command_line)
{
char *s = g_strdup (command_line);
char *s2;
for (s2 = s; *s2; s2++) /* truncate at first whitespace */
if (isspace (*s2)) {
*s2 = 0;
break;
}
s2 = g_basename (s);
if (strlen (s2) > 50) /* Truncate after 50 characters */
s2[50] = '\0';
return s2;
}
static char *
get_label (char *name)
{
char *s, *label;
label = screensaver_get_label_from_xrdb (name);
if (label) return label;
label = g_strdup (name);
for (s = label; *s; s++) /* if it has any capitals, return it */
if (*s >= 'A' && *s <= 'Z')
return s;
if (label[0] >= 'a' && label[0] <= 'z') /* else cap it */
label[0] -= 'a'-'A';
if (label[0] == 'X' && label[1] >= 'a' && label[1] <= 'z')
label[1] -= 'a'-'A';
return label;
}
/* WARNING: Looking at the following code is likely to cause seizures ... */
static gchar *
strip_whitespace (const gchar *line)
{
gchar *line2, *s;
s = line2 = g_new0 (char, strlen (line));
while (*line) {
if (!isspace (*line))
*line2++ = *line++;
else if (*++line && !isspace (*line))
*line2++ = ' ';
}
return s;
}
/* command_exists
*
* Given a command line, determines if the command may be executed
*/
static gboolean
command_exists (char *command)
{
char *program, *fullpath;
static char **path_dirs;
int i;
gboolean ret;
program = g_strdup (command);
/* Truncate at first whitespace */
for (i = 0; program[i] && !isspace (program[i]); i++);
program[i] = '\0';
/* If this is a complete path, then just stat it */
if (strchr (program, '/')) {
if (g_file_test (program, G_FILE_TEST_ISFILE))
ret = TRUE;
else
ret = FALSE;
g_free (program);
return ret;
}
/* Check the /usr/X11R6/lib/xscreensaver/ directory */
fullpath = g_concat_dir_and_file ("/usr/X11R6/lib/xscreensaver",
program);
if (g_file_test (fullpath, G_FILE_TEST_ISFILE)) {
g_free (program);
g_free (fullpath);
return TRUE;
}
g_free (fullpath);
fullpath = gnome_is_program_in_path (program);
if (fullpath)
ret = TRUE;
else
ret = FALSE;
if (fullpath) g_free (fullpath);
g_free (program);
return ret;
}
/* Adapted from xscreensaver 3.24 driver/prefs.c line 900 ...
*
* Parsing the programs resource.
*/
static Screensaver *
parse_screensaver (const char *line)
{
Screensaver *h;
const char *s;
h = screensaver_new ();
while (isspace(*line)) line++; /* skip whitespace */
if (*line == '-') { /* handle "-" */
h->enabled = FALSE;
line++;
while (isspace(*line)) line++; /* skip whitespace */
}
s = line; /* handle "visual:" */
while (*line && *line != ':' && *line != '"' && !isspace(*line))
line++;
if (*line != ':')
line = s;
else {
h->visual = g_strndup (s, line - s);
if (*line == ':') line++; /* skip ":" */
while (isspace(*line)) line++; /* skip whitespace */
}
if (*line == '"') { /* handle "name" */
line++;
s = line;
while (*line && *line != '"') line++;
h->label = g_strndup (s, line - s);
if (*line == '"') line++; /* skip "\"" */
while (isspace(*line)) line++; /* skip whitespace */
}
h->command_line = strip_whitespace (line);
if (!command_exists (h->command_line)) {
screensaver_destroy (h);
return NULL;
}
h->name = get_settings_name (h->command_line);
if (!h->label) h->label = get_label (h->name);
return h;
}
/* Adapted from xscreensaver 3.24 driver/prefs.c line 1076 ... */
GList *
parse_screensaver_list (char *list)
{
int start = 0;
int end = 0;
int size = 0;
int count = 0;
int number_enabled = 0;
int total = 0;
GList *list_head = NULL, *list_tail = NULL;
Screensaver *saver;
size = strlen (list);
/* Iterate over the lines in `d' (the string with newlines)
and make new strings to stuff into the `screenhacks' array.
*/
while (start < size) {
/* skip forward over whitespace. */
while (list[start] == ' ' ||
list[start] == '\t' ||
list[start] == '\n')
start++;
/* skip forward to newline or end of string. */
end = start;
while (list[end] != 0 && list[end] != '\n')
end++;
/* null terminate. */
list[end] = 0;
saver = parse_screensaver (list + start);
if (saver) {
saver->id = count++;
if (saver->enabled) number_enabled++;
total++;
list_tail = g_list_append (list_tail, saver);
if (!list_head) list_head = list_tail;
list_tail = g_list_last (list_tail);
saver->link = list_tail;
}
start = end + 1;
}
return list_head;
}
gchar *
write_boolean (gboolean value)
{
return value ? g_strdup ("True") : g_strdup ("False");
}
gchar *
write_integer (gint value)
{
return g_strdup_printf ("%d", value);
}
gchar *
write_float (gfloat value)
{
return g_strdup_printf ("%f", value);
}
gchar *
write_time (time_t value)
{
return g_strdup_printf ("%u:%02u:%02u",
(guint) value / 60 / 60,
(guint) (value / 60) % 60,
(guint) value % 60);
}
gchar *
write_seconds (gint value)
{
return write_time ((time_t) value);
}
gchar *
write_minutes (gdouble value)
{
return write_time ((time_t) (value * 60.0));
}
/* From xscreensaver 3.24 driver/prefs.c line 963 ... */
static char *
format_command (const char *cmd, gboolean wrap_p)
{
int tab = 30;
int col = tab;
char *cmd2 = g_new0 (char, 2 * (strlen (cmd) + 1));
const char *in = cmd;
char *out = cmd2;
while (*in) {
/* shrink all whitespace to one space, for the benefit
* of the "demo" mode display. We only do this when
* we can easily tell that the whitespace is not
* significant (no shell metachars).
*/
switch (*in) {
case '\'': case '"': case '`': case '\\':
/* Metachars are scary. Copy the rest of the
* line unchanged. */
while (*in)
*out++ = *in++, col++;
break;
case ' ': case '\t':
/* Squeeze all other whitespace down to one space. */
while (*in == ' ' || *in == '\t')
in++;
*out++ = ' ', col++;
break;
default:
/* Copy other chars unchanged. */
*out++ = *in++, col++;
break;
}
}
*out = 0;
/* Strip trailing whitespace */
while (out > cmd2 && isspace (out[-1]))
*(--out) = 0;
return cmd2;
}
/* From xscreensaver 3.24 driver/prefs.c line 415 ... */
static char *
stab_to (char *out, int from, int to)
{
int tab_width = 8;
int to_mod = (to / tab_width) * tab_width;
while (from < to_mod) {
*out++ = '\t';
from = (((from / tab_width) + 1) * tab_width);
}
while (from < to) {
*out++ = ' ';
from++;
}
return out;
}
int
string_columns (const char *string, int length, int start)
{
int tab_width = 8;
int col = start;
const char *end = string + length;
while (string < end) {
if (*string == '\n')
col = 0;
else if (*string == '\t')
col = (((col / tab_width) + 1) * tab_width);
else
col++;
string++;
}
return col;
}
/* From xscreensaver 3.24 driver/prefs.c line 1009 ... */
static char *
format_hack (Screensaver *saver, gboolean wrap_p)
{
int tab = 32;
int size = (2 * (strlen(saver->command_line) +
(saver->visual ? strlen(saver->visual) : 0) +
(saver->name ? strlen(saver->name) : 0) +
tab));
char *h2 = g_new (char, size);
char *out = h2;
char *s;
int col = 0;
if (!saver->enabled) *out++ = '-'; /* write disabled flag */
if (saver->visual && *saver->visual) { /* write visual name */
if (saver->enabled) *out++ = ' ';
*out++ = ' ';
strcpy (out, saver->visual);
out += strlen (saver->visual);
*out++ = ':';
*out++ = ' ';
}
*out = 0;
col = string_columns (h2, strlen (h2), 0);
if (saver->label && *saver->label) { /* write pretty name */
int L = (strlen (saver->label) + 2);
if (L + col < tab)
out = stab_to (out, col, tab - L - 2);
else
*out++ = ' ';
*out++ = '"';
strcpy (out, saver->label);
out += strlen (saver->label);
*out++ = '"';
*out = 0;
col = string_columns (h2, strlen (h2), 0);
if (wrap_p && col >= tab) {
out = stab_to (out, col, 77);
*out += strlen(out);
}
else
*out++ = ' ';
if (out >= h2+size) abort();
}
*out = 0;
col = string_columns (h2, strlen (h2), 0);
out = stab_to (out, col, tab); /* indent */
if (out >= h2+size) abort();
s = format_command (saver->command_line, wrap_p);
strcpy (out, s);
out += strlen (s);
g_free (s);
*out = 0;
return h2;
}
gchar *
write_screensaver_list (GList *screensavers)
{
GList *node;
Screensaver *saver;
GString *hack_string;
gchar *str;
hack_string = g_string_new (NULL);
node = screensavers;
while (node) {
saver = SCREENSAVER (node->data);
str = format_hack (saver, TRUE);
g_string_append (hack_string, str);
g_string_append (hack_string, "\n");
node = node->next;
g_free (str);
}
str = hack_string->str;
g_string_free (hack_string, FALSE);
return str;
}

View File

@@ -1,48 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* rc-parse.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifndef __RC_PARSE_H
#define __RC_PARSE_H
#include <glib.h>
gboolean parse_boolean_resource (char *res);
int parse_integer_resource (char *res);
double parse_float_resource (char *res);
guint parse_time_resource (char *res, gboolean sec);
guint parse_seconds_resource (char *res);
gdouble parse_minutes_resource (char *res);
GList *parse_screensaver_list (char *list);
gchar *write_boolean (gboolean value);
gchar *write_integer (gint value);
gchar *write_float (gfloat value);
gchar *write_time (time_t value);
gchar *write_seconds (gint value);
gchar *write_minutes (gdouble value);
gchar *write_screensaver_list (GList *screensavers);
/* Internal; used by pref-file.c and rc-parse.c only */
int string_columns (const char *string, int length, int start);
#endif /* __RC_PARSE_H */

View File

@@ -1,138 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* resources.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <X11/Intrinsic.h>
#include <X11/Shell.h>
#include <gdk/gdkprivate.h>
#include "resources.h"
#include "rc-parse.h"
static char *defaults[] = {
#include "XScreenSaver_ad.h"
0
};
static XrmDatabase db;
void
init_resource_database (int argc, char **argv)
{
XtAppContext app;
Widget toplevel_shell;
Display *dpy;
/* From xscreensaver 3.24 display/demo-Gtk.c line 1908 ... */
XtToolkitInitialize ();
app = XtCreateApplicationContext ();
dpy = gdk_display;
XtAppSetFallbackResources (app, defaults);
XtDisplayInitialize (app, dpy, "xscreensaver", "XScreenSaver",
0, 0, &argc, argv);
toplevel_shell = XtAppCreateShell ("xscreensaver", "XScreenSaver",
applicationShellWidgetClass,
dpy, 0, 0);
dpy = XtDisplay (toplevel_shell);
db = XtDatabase (dpy);
}
/* From xscreensaver 3.24 utils/resource.c line 34 ... */
static char *
get_resource (char *res_name, char *res_class)
{
XrmValue value;
char *type, *value_str = NULL, *full_name, *full_class;
full_name = g_strconcat ("xscreensaver.", res_name, NULL);
full_class = g_strconcat ("XScreenSaver.", res_class, NULL);
if (XrmGetResource (db, full_name, full_class, &type, &value))
value_str = g_strndup (value.addr, value.size);
g_free (full_name);
g_free (full_class);
return value_str;
}
static gchar *rc_names[][2] = {
{ "verbose", "Boolean" },
{ "lock", "Boolean" },
{ "lockVTs", "Boolean" },
{ "fade", "Boolean" },
{ "unfade", "Boolean" },
{ "fadeSeconds", "Time" },
{ "fadeTicks", "Integer" },
{ "installColormap", "Boolean" },
{ "nice", "Nice" },
{ "timeout", "Time" },
{ "lockTimeout", "Time" },
{ "cycle", "Time" },
{ "passwdTimeout", "Time" },
{ "xidleExtension", "Boolean" },
{ "mitSaverExtension", "Boolean" },
{ "sgiSaverExtension", "Boolean" },
{ "procInterrupts", "Boolean" },
{ "bourneShell", "BourneShell" },
{ "programs", "Programs" },
{ NULL, NULL }
};
void
preferences_load_from_xrdb (Preferences *prefs)
{
int i;
prefs->config_db = g_tree_new ((GCompareFunc) strcmp);
for (i = 0; rc_names[i][0]; i++)
g_tree_insert (prefs->config_db, rc_names[i][0],
get_resource (rc_names[i][0], rc_names[i][1]));
}
void
screensaver_get_desc_from_xrdb (Screensaver *saver)
{
gchar *s;
s = g_strconcat ("hacks.", saver->name, ".documentation", NULL);
saver->description = get_resource (s, s);
g_free (s);
}
gchar *
screensaver_get_label_from_xrdb (gchar *name)
{
gchar *s;
s = g_strdup_printf ("hacks.%s.name", name);
return get_resource (s, s);
}

View File

@@ -1,37 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* resources.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifndef __RESOURCES_H
#define __RESOURCES_H
#include "preferences.h"
void init_resource_database (int argc, char **argv);
void preferences_load_from_xrdb (Preferences *prefs);
void screensaver_get_desc_from_xrdb (Screensaver *saver);
gchar *screensaver_get_label_from_xrdb (gchar *name);
#endif /* __RESOURCES_H */

View File

@@ -1,953 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* screensaver-prefs-dialog.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <gnome.h>
#include <parser.h>
#include <sys/stat.h>
#include <glade/glade.h>
#include "screensaver-prefs-dialog.h"
#include "preferences.h"
#include "expr.h"
#include "preview.h"
struct _cli_argument_t
{
char *argument;
char *value;
};
typedef struct _cli_argument_t cli_argument_t;
enum {
OK_CLICKED_SIGNAL,
DEMO_SIGNAL,
LAST_SIGNAL
};
static gint screensaver_prefs_dialog_signals[LAST_SIGNAL] = { 0 };
static void screensaver_prefs_dialog_init (ScreensaverPrefsDialog *dialog);
static void screensaver_prefs_dialog_class_init (ScreensaverPrefsDialogClass *dialog);
static void set_widgets_sensitive (GladeXML *prop_data,
gchar *widgets_str,
gboolean s);
static void activate_option_cb (GtkWidget *widget);
static void toggle_check_cb (GtkWidget *widget,
xmlNodePtr node);
static gchar *write_boolean (xmlNodePtr arg_def,
GladeXML *prop_data);
static gchar *write_number (xmlNodePtr arg_def,
GladeXML *prop_data);
static gchar *write_select (xmlNodePtr arg_def,
GladeXML *prop_data);
static gchar *write_command_line (gchar *name,
xmlNodePtr arg_def,
GladeXML *prop_data);
static GScanner *read_command_line (char *command_line);
static xmlNodePtr get_argument_data (Screensaver *saver);
static GladeXML *get_screensaver_widget (Screensaver *saver,
xmlNodePtr argument_data);
static gint arg_is_set (xmlNodePtr argument_data,
GScanner *cli_db);
static void read_boolean (GladeXML *widget_data,
xmlNodePtr argument_data,
GScanner *cli_db);
static void read_number (GladeXML *widget_data,
xmlNodePtr argument_data,
GScanner *cli_db);
static void read_select (GladeXML *widget_data,
xmlNodePtr argument_data,
GScanner *cli_db);
static void place_screensaver_properties (ScreensaverPrefsDialog *dialog);
static gboolean arg_mapping_exists (Screensaver *saver);
static void store_cli (ScreensaverPrefsDialog *dialog);
static GtkWidget *get_basic_screensaver_widget (ScreensaverPrefsDialog *dialog,
Screensaver *saver);
static void demo_cb (GtkWidget *widget,
ScreensaverPrefsDialog *dialog);
static void help_cb (GtkWidget *widget,
ScreensaverPrefsDialog *dialog);
static void screensaver_prop_ok_cb (GtkWidget *widget,
ScreensaverPrefsDialog *dialog);
static void screensaver_prop_cancel_cb (GtkWidget *widget,
ScreensaverPrefsDialog *dialog);
guint
screensaver_prefs_dialog_get_type (void)
{
static guint screensaver_prefs_dialog_type = 0;
if (!screensaver_prefs_dialog_type) {
GtkTypeInfo screensaver_prefs_dialog_info = {
"ScreensaverPrefsDialog",
sizeof (ScreensaverPrefsDialog),
sizeof (ScreensaverPrefsDialogClass),
(GtkClassInitFunc) screensaver_prefs_dialog_class_init,
(GtkObjectInitFunc) screensaver_prefs_dialog_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL
};
screensaver_prefs_dialog_type =
gtk_type_unique (gnome_dialog_get_type (),
&screensaver_prefs_dialog_info);
}
return screensaver_prefs_dialog_type;
}
static void
screensaver_prefs_dialog_init (ScreensaverPrefsDialog *dialog)
{
GtkWidget *global_vbox, *vbox, *hbox, *frame, *label;
gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, FALSE, FALSE);
global_vbox = GNOME_DIALOG (dialog)->vbox;
hbox = gtk_hbox_new (FALSE, 5);
gtk_box_pack_start (GTK_BOX (global_vbox), hbox, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
label = gtk_label_new (_("Name:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
dialog->name_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), dialog->name_entry, TRUE, TRUE, 0);
hbox = gtk_hbox_new (FALSE, 10);
gtk_box_pack_start (GTK_BOX (global_vbox), hbox, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
dialog->settings_dialog_frame = gtk_frame_new (_("Settings"));
gtk_box_pack_start (GTK_BOX (hbox), dialog->settings_dialog_frame,
TRUE, TRUE, 0);
vbox = gtk_vbox_new (FALSE, 10);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
frame = gtk_frame_new (_("Description"));
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
dialog->description = gtk_label_new (_("label1"));
gtk_container_add (GTK_CONTAINER (frame), dialog->description);
gtk_label_set_justify (GTK_LABEL (dialog->description),
GTK_JUSTIFY_LEFT);
gtk_label_set_line_wrap (GTK_LABEL (dialog->description), TRUE);
gtk_misc_set_alignment (GTK_MISC (dialog->description), 0, 0);
gtk_misc_set_padding (GTK_MISC (dialog->description), 5, 5);
gnome_dialog_append_button (GNOME_DIALOG (dialog),
_("Demo"));
gnome_dialog_append_button (GNOME_DIALOG (dialog),
GNOME_STOCK_BUTTON_HELP);
gnome_dialog_append_button (GNOME_DIALOG (dialog),
GNOME_STOCK_BUTTON_OK);
gnome_dialog_append_button (GNOME_DIALOG (dialog),
GNOME_STOCK_BUTTON_CANCEL);
gtk_widget_show_all (global_vbox);
}
static void
screensaver_prefs_dialog_class_init (ScreensaverPrefsDialogClass *class)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *) class;
screensaver_prefs_dialog_signals[OK_CLICKED_SIGNAL] =
gtk_signal_new ("ok-clicked", GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET
(ScreensaverPrefsDialogClass, ok_clicked),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
screensaver_prefs_dialog_signals[DEMO_SIGNAL] =
gtk_signal_new ("demo", GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET
(ScreensaverPrefsDialogClass, demo),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class,
screensaver_prefs_dialog_signals,
LAST_SIGNAL);
class->ok_clicked = NULL;
}
GtkWidget *
screensaver_prefs_dialog_new (Screensaver *saver)
{
GtkWidget *widget;
ScreensaverPrefsDialog *dialog;
char *title;
widget = gtk_type_new (screensaver_prefs_dialog_get_type ());
dialog = SCREENSAVER_PREFS_DIALOG (widget);
dialog->saver = saver;
title = g_strconcat (saver->label, " properties", NULL);
gtk_entry_set_text (GTK_ENTRY (dialog->name_entry),
saver->label);
if (arg_mapping_exists (saver)) {
dialog->cli_args_db =
read_command_line (saver->command_line);
dialog->argument_data = get_argument_data (saver);
dialog->prefs_widget_data =
get_screensaver_widget (saver,
dialog->argument_data);
} else {
dialog->basic_widget =
get_basic_screensaver_widget (dialog, saver);
}
gtk_window_set_title (GTK_WINDOW (dialog), title);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0,
demo_cb, dialog);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1,
help_cb, dialog);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 2,
screensaver_prop_ok_cb, dialog);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 3,
screensaver_prop_cancel_cb, dialog);
if (dialog->basic_widget)
gtk_container_add (GTK_CONTAINER
(dialog->settings_dialog_frame),
dialog->basic_widget);
else if (dialog->prefs_widget_data)
gtk_container_add (GTK_CONTAINER
(dialog->settings_dialog_frame),
glade_xml_get_widget
(dialog->prefs_widget_data,
"widget"));
gtk_label_set_text (GTK_LABEL (dialog->description),
screensaver_get_desc (saver));
if (dialog->argument_data)
place_screensaver_properties (dialog);
return widget;
}
/*****************************************************************************/
/* Enabling/disabling widgets based on options selected */
/*****************************************************************************/
/* set_widgets_sensitive
*
* Given a string of comma-separated widget names, finds the widgets
* in the given Glade XML definition and enables or disables them,
* based on the value of s
*/
static void
set_widgets_sensitive (GladeXML *prop_data, gchar *widgets_str, gboolean s)
{
char **widgets;
int i;
GtkWidget *widget;
if (!widgets_str) return;
widgets = g_strsplit (widgets_str, ",", -1);
for (i = 0; widgets[i]; i++) {
widget = glade_xml_get_widget (prop_data, widgets[i]);
if (widget) gtk_widget_set_sensitive (widget, s);
}
g_strfreev (widgets);
}
/* activate_option_cb
*
* Callback invoked when an option on an option menu is selected. The
* callback scans the xml node corresponding with that option to see
* what widgets are enabled by selecting that option and uses
* set_widgets_sensitive to enable them. Iterates through all other
* XML nodes and disables those widgets enabled by other nodes.
*/
static void
activate_option_cb (GtkWidget *widget)
{
GladeXML *prop_data;
xmlNodePtr argument_data, option_def, node;
prop_data = gtk_object_get_data (GTK_OBJECT (widget),
"prop_data");
argument_data = gtk_object_get_data (GTK_OBJECT (widget),
"argument_data");
option_def = gtk_object_get_data (GTK_OBJECT (widget),
"option_def");
node = argument_data->childs;
while (node) {
if (node != option_def)
set_widgets_sensitive (prop_data,
xmlGetProp (node, "enable"),
FALSE);
node = node->next;
}
set_widgets_sensitive (prop_data,
xmlGetProp (option_def, "enable"), TRUE);
}
/* toggle_check_cb
*
* Callback invoked when a check button is toggled. Works in a manner
* analagous to select_option_cb and deselect_option_cb above.
*/
static void
toggle_check_cb (GtkWidget *widget, xmlNodePtr node)
{
GladeXML *prop_data;
gboolean set;
prop_data = gtk_object_get_data (GTK_OBJECT (widget),
"prop_data");
set = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
set_widgets_sensitive (prop_data,
xmlGetProp (node, "enable"),
set);
}
/*****************************************************************************/
/* Writing out command lines */
/*****************************************************************************/
static gchar *
write_boolean (xmlNodePtr argument_data, GladeXML *prop_data)
{
char *widget_name;
GtkWidget *widget;
widget_name = g_strconcat (xmlGetProp (argument_data, "id"),
"_widget", NULL);
widget = glade_xml_get_widget (prop_data, widget_name);
g_free (widget_name);
if (!widget || !GTK_WIDGET_IS_SENSITIVE (widget)) return NULL;
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
return xmlGetProp (argument_data, "arg-set");
else
return NULL;
}
static gchar *
write_number (xmlNodePtr argument_data, GladeXML *prop_data)
{
char *widget_name;
GtkWidget *widget;
GtkAdjustment *adjustment = NULL;
gfloat value = 0.0;
gchar *to_cli_expr;
widget_name = g_strconcat (xmlGetProp (argument_data, "id"),
"_widget", NULL);
widget = glade_xml_get_widget (prop_data, widget_name);
g_free (widget_name);
if (!widget || !GTK_WIDGET_IS_SENSITIVE (widget)) return NULL;
if (GTK_IS_RANGE (widget))
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
else if (GTK_IS_SPIN_BUTTON (widget))
adjustment = gtk_spin_button_get_adjustment
(GTK_SPIN_BUTTON (widget));
if (adjustment)
value = adjustment->value;
to_cli_expr = xmlGetProp (argument_data, "to-cli-conv");
if (to_cli_expr)
value = parse_expr (to_cli_expr, value);
return g_strdup_printf (xmlGetProp (argument_data, "arg"), (int) value);
}
/* Note to readers: *please* ignore the following function, for the
* sake of your own mental health and my reputation as a sane
* coder. Just accept that it returns a string containing the CLI
* arguments corresponding with the selected option of an option
* menu. *sigh* I really must ask someone if there's a better way to
* do this...
*/
static gchar *
write_select (xmlNodePtr argument_data, GladeXML *prop_data)
{
xmlNodePtr node;
int i = 0;
GtkWidget *widget, *menu, *active;
char *widget_name;
GList *menu_item;
node = argument_data->childs;
widget_name = g_strconcat (xmlGetProp (argument_data, "id"),
"_widget", NULL);
widget = glade_xml_get_widget (prop_data, widget_name);
if (!widget || !GTK_WIDGET_IS_SENSITIVE (widget)) return NULL;
menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (widget));
menu_item = GTK_MENU_SHELL (menu)->children;
active = gtk_menu_get_active (GTK_MENU (menu));
while (node && menu_item) {
if (active == menu_item->data &&
!xmlGetProp (node, "no-output"))
return xmlGetProp (node, "arg-set");
node = node->next; menu_item = menu_item->next; i++;
}
return NULL;
}
/* write_command_line
*
* Scan through XML nodes in the argument definition file and write
* out the parameter corresponding to each node in turn.
*/
static gchar *
write_command_line (gchar *name, xmlNodePtr argument_data, GladeXML *prop_data)
{
GString *line;
xmlNodePtr node;
gchar *arg, *ret;
line = g_string_new (name);
node = argument_data->childs;
for (node = argument_data->childs; node; node = node->next) {
if (xmlGetProp (node, "no-output"))
continue;
if (!strcmp (node->name, "boolean"))
arg = write_boolean (node, prop_data);
else if (!strcmp (node->name, "number"))
arg = write_number (node, prop_data);
else if (!strcmp (node->name, "select"))
arg = write_select (node, prop_data);
else if (!strcmp (node->name, "command"))
arg = xmlGetProp (node, "arg");
else
arg = NULL;
if (arg) {
g_string_append (line, " ");
g_string_append (line, arg);
}
}
ret = line->str;
g_string_free (line, FALSE);
return ret;
}
/*****************************************************************************/
/* Reading the command line */
/*****************************************************************************/
static GScanner *
read_command_line (char *command_line)
{
char **args;
int i;
GScanner *cli_db;
static GScannerConfig config;
char *arg, *value;
config.cset_skip_characters = " \t\n";
config.cset_identifier_first = "abcdefghijklmnopqrstuvwxyz";
config.cset_identifier_nth = "abcdefghijklmnopqrstuvwxyz_";
config.scan_symbols = TRUE;
config.scan_identifier = TRUE;
cli_db = g_scanner_new (&config);
g_scanner_set_scope (cli_db, 0);
args = g_strsplit (command_line, " ", -1);
g_scanner_scope_add_symbol (cli_db, 0, "and", SYMBOL_AND);
g_scanner_scope_add_symbol (cli_db, 0, "or", SYMBOL_OR);
g_scanner_scope_add_symbol (cli_db, 0, "not", SYMBOL_NOT);
for (i = 0; args[i]; i++) {
if (args[i][0] == '-') {
arg = g_strdup (args[i] + 1);
if (args[i + 1] && args[i + 1][0] != '-') {
value = g_strdup (args[i + 1]);
i++;
} else {
value = (char *) 1;
}
g_scanner_scope_add_symbol (cli_db, 0, arg, value);
}
}
g_strfreev (args);
return cli_db;
}
/*****************************************************************************/
/* Getting the argument definition data */
/*****************************************************************************/
static xmlNodePtr
get_argument_data (Screensaver *saver)
{
xmlDocPtr doc;
xmlNodePtr root_node, node;
gchar *name;
doc = xmlParseFile (SSPROP_DATADIR "/hacks.xml");
root_node = xmlDocGetRootElement (doc);
g_assert (root_node != NULL);
node = root_node->childs;
while (node) {
name = xmlGetProp (node, "name");
if (!strcmp (name, saver->name)) break;
node = node->next;
}
return node;
}
/*****************************************************************************/
/* Creating the dialog proper */
/*****************************************************************************/
static GladeXML *
get_screensaver_widget (Screensaver *saver,
xmlNodePtr argument_data)
{
GladeXML *screensaver_prop_data;
gchar *file_name;
file_name = g_strconcat (SSPROP_DATADIR "/",
saver->name, "-settings.glade", NULL);
screensaver_prop_data = glade_xml_new (file_name, "widget");
g_free (file_name);
return screensaver_prop_data;
}
/*****************************************************************************/
/* Setting dialog properties from the CLI */
/*****************************************************************************/
/* arg_is_set
*
* Determines if an argument or set of arguments specified by the
* argument definition entry is set on a command line. Returns -1 if
* the argument is definitely not set, 0 if it may be, and 1 if it
* definitely is.
*/
static gint
arg_is_set (xmlNodePtr argument_data, GScanner *cli_db)
{
char *test;
test = xmlGetProp (argument_data, "test");
if (test) {
return parse_sentence (test, cli_db) ? 1 : -1;
} else {
return 0;
}
}
static void
read_boolean (GladeXML *widget_data, xmlNodePtr argument_data,
GScanner *cli_db)
{
char *widget_name;
GtkWidget *widget;
gint found;
found = arg_is_set (argument_data, cli_db);
widget_name = g_strconcat (xmlGetProp (argument_data, "id"),
"_widget", NULL);
widget = glade_xml_get_widget (widget_data, widget_name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
found >= 0);
gtk_object_set_data (GTK_OBJECT (widget), "prop_data",
widget_data);
gtk_signal_connect (GTK_OBJECT (widget), "toggled",
GTK_SIGNAL_FUNC (toggle_check_cb),
argument_data);
if (found >= 0) {
set_widgets_sensitive (widget_data,
xmlGetProp (argument_data, "enable"),
TRUE);
} else {
set_widgets_sensitive (widget_data,
xmlGetProp (argument_data, "enable"),
FALSE);
}
}
static void
read_number (GladeXML *widget_data, xmlNodePtr argument_data,
GScanner *cli_db)
{
char *arg;
char *arg_line;
char **args;
char *widget_name;
char *from_cli_conv;
GtkWidget *widget;
GtkAdjustment *adjustment;
gfloat value;
arg_line = xmlGetProp (argument_data, "arg");
args = g_strsplit (arg_line, " ", -1);
arg = g_scanner_scope_lookup_symbol (cli_db, 0, args[0] + 1);
if (!arg) return;
widget_name = g_strconcat (xmlGetProp (argument_data, "id"),
"_widget", NULL);
widget = glade_xml_get_widget (widget_data, widget_name);
from_cli_conv = xmlGetProp (argument_data, "from-cli-conv");
if (from_cli_conv)
value = parse_expr (from_cli_conv, atof (arg));
else
value = atof (arg);
if (GTK_IS_RANGE (widget)) {
adjustment = gtk_range_get_adjustment (GTK_RANGE (widget));
gtk_adjustment_set_value (adjustment, value);
}
else if (GTK_IS_SPIN_BUTTON (widget)) {
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
}
g_strfreev (args);
}
static void
read_select (GladeXML *widget_data, xmlNodePtr argument_data,
GScanner *cli_db)
{
xmlNodePtr node;
gchar *widget_name;
GtkWidget *widget, *menu;
GList *menu_item_node;
gint found, max_found = -1;
int set_idx = 0, i = 0;
widget_name = g_strconcat (xmlGetProp (argument_data, "id"),
"_widget", NULL);
widget = glade_xml_get_widget (widget_data, widget_name);
menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (widget));
node = argument_data->childs;
/* Get the index of the selected option */
while (node) {
found = arg_is_set (node, cli_db);
if (found > max_found) {
set_idx = i;
max_found = found;
}
node = node->next; i++;
}
/* Enable widgets enabled by selected option and disable
* widgets enabled by other options; connect select and
* deselect signals to do the same when an option is selected
*/
menu_item_node = GTK_MENU_SHELL (menu)->children;
node = argument_data->childs; i = 0;
while (node) {
if (i == set_idx) {
gtk_option_menu_set_history
(GTK_OPTION_MENU (widget), i);
set_widgets_sensitive (widget_data,
xmlGetProp (node, "enable"),
TRUE);
} else {
set_widgets_sensitive (widget_data,
xmlGetProp (node, "enable"),
FALSE);
}
gtk_object_set_data (GTK_OBJECT (menu_item_node->data),
"prop_data", widget_data);
gtk_object_set_data (GTK_OBJECT (menu_item_node->data),
"option_def", node);
gtk_object_set_data (GTK_OBJECT (menu_item_node->data),
"argument_data", argument_data);
gtk_signal_connect (GTK_OBJECT (menu_item_node->data),
"activate",
GTK_SIGNAL_FUNC (activate_option_cb),
NULL);
node = node->next; menu_item_node = menu_item_node->next; i++;
}
}
static void
place_screensaver_properties (ScreensaverPrefsDialog *dialog)
{
xmlNodePtr node;
node = dialog->argument_data->childs;
while (node) {
if (!strcmp (node->name, "boolean"))
read_boolean (dialog->prefs_widget_data, node,
dialog->cli_args_db);
else if (!strcmp (node->name, "number"))
read_number (dialog->prefs_widget_data, node,
dialog->cli_args_db);
else if (!strcmp (node->name, "select"))
read_select (dialog->prefs_widget_data, node,
dialog->cli_args_db);
node = node->next;
}
}
static gboolean
arg_mapping_exists (Screensaver *saver)
{
struct stat buf;
char *filename;
gboolean ret;
if (!saver->name) return FALSE;
filename = g_strconcat (SSPROP_DATADIR "/",
saver->name, "-settings.glade", NULL);
if (stat (filename, &buf))
ret = FALSE;
else
ret = TRUE;
g_free (filename);
return ret;
}
static void
store_cli (ScreensaverPrefsDialog *dialog)
{
char *str;
g_free (dialog->saver->command_line);
if (dialog->prefs_widget_data) {
dialog->saver->command_line =
write_command_line (dialog->saver->name,
dialog->argument_data,
dialog->prefs_widget_data);
} else {
dialog->saver->command_line =
g_strdup (gtk_entry_get_text
(GTK_ENTRY (dialog->cli_entry)));
str = gtk_entry_get_text
(GTK_ENTRY (GTK_COMBO
(dialog->visual_combo)->entry));
if (!strcmp (str, "Any")) {
dialog->saver->visual = NULL;
} else {
dialog->saver->visual = g_strdup (str);
g_strdown (dialog->saver->visual);
}
}
}
/*****************************************************************************/
/* Fallback when Glade definition not found */
/*****************************************************************************/
static GtkWidget *
get_basic_screensaver_widget (ScreensaverPrefsDialog *dialog,
Screensaver *saver)
{
GtkWidget *vbox, *label;
GList *node;
vbox = gtk_vbox_new (FALSE, 10);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
if (saver->name) {
label = gtk_label_new (_("Cannot find the data to configure this screensaver. Please edit the command line below."));
} else {
label = gtk_label_new (_("Please enter a command line below."));
}
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 5);
dialog->cli_entry = gtk_entry_new ();
if (saver->command_line) {
gtk_entry_set_text (GTK_ENTRY (dialog->cli_entry),
saver->command_line);
}
gtk_box_pack_start (GTK_BOX (vbox), dialog->cli_entry,
TRUE, FALSE, 5);
label = gtk_label_new (_("Visual:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 1.0);
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, TRUE, 5);
dialog->visual_combo = gtk_combo_new ();
node = g_list_alloc ();
node->data = "Any";
g_list_append (node, "Best");
g_list_append (node, "Default");
g_list_append (node, "Default-N");
g_list_append (node, "GL");
g_list_append (node, "TrueColor");
g_list_append (node, "PseudoColor");
g_list_append (node, "StaticGray");
g_list_append (node, "GrayScale");
g_list_append (node, "DirectColor");
g_list_append (node, "Color");
g_list_append (node, "Gray");
g_list_append (node, "Mono");
gtk_combo_set_popdown_strings (GTK_COMBO (dialog->visual_combo), node);
if (saver->visual)
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO
(dialog->visual_combo)->entry),
saver->visual);
else
gtk_entry_set_text (GTK_ENTRY (GTK_COMBO
(dialog->visual_combo)->entry),
"Any");
gtk_box_pack_start (GTK_BOX (vbox), dialog->visual_combo,
TRUE, FALSE, 5);
return vbox;
}
/*****************************************************************************/
/* Global dialog callbacks */
/*****************************************************************************/
static void
demo_cb (GtkWidget *widget, ScreensaverPrefsDialog *dialog)
{
store_cli (dialog);
gtk_signal_emit (GTK_OBJECT (dialog),
screensaver_prefs_dialog_signals[DEMO_SIGNAL]);
show_demo (dialog->saver);
}
static void
help_cb (GtkWidget *widget, ScreensaverPrefsDialog *dialog)
{
GnomeHelpMenuEntry entry;
gchar *url;
if (!dialog->saver->name) return;
if (dialog->prefs_widget_data) {
entry.name = "screensaver-properties-capplet";
entry.path = g_strconcat (dialog->saver->name, ".html", NULL);
if (entry.path) {
gnome_help_display (NULL, &entry);
g_free (entry.path);
}
} else {
url = g_strconcat ("man:", dialog->saver->name, NULL);
gnome_url_show (url);
g_free (url);
}
}
static void
screensaver_prop_ok_cb (GtkWidget *widget, ScreensaverPrefsDialog *dialog)
{
store_cli (dialog);
g_free (dialog->saver->label);
dialog->saver->label =
g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
gtk_signal_emit (GTK_OBJECT (dialog),
screensaver_prefs_dialog_signals[OK_CLICKED_SIGNAL]);
gnome_dialog_close (GNOME_DIALOG (dialog));
}
static void
screensaver_prop_cancel_cb (GtkWidget *widget, ScreensaverPrefsDialog *dialog)
{
gnome_dialog_close (GNOME_DIALOG (dialog));
}

View File

@@ -1,72 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* screensaver-prefs-dialog.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
*
* 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.
*/
#ifndef __SCREENSAVER_PREFS_DIALOG_H
#define __SCREENSAVER_PREFS_DIALOG_H
#include <gnome.h>
#include <tree.h>
#include <glade/glade.h>
#include "preferences.h"
#include "prefs-widget.h"
#define SCREENSAVER_PREFS_DIALOG(obj) GTK_CHECK_CAST (obj, screensaver_prefs_dialog_get_type (), ScreensaverPrefsDialog)
#define SCREENSAVER_PREFS_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, screensaver_prefs_dialog_get_type (), ScreensaverPrefsDialogClass)
#define IS_SCREENSAVER_PREFS_DIALOG(obj) GTK_CHECK_TYPE (obj, screensaver_prefs_dialog_get_type ())
typedef struct _ScreensaverPrefsDialog ScreensaverPrefsDialog;
typedef struct _ScreensaverPrefsDialogClass ScreensaverPrefsDialogClass;
struct _ScreensaverPrefsDialog
{
GnomeDialog gnome_dialog;
Screensaver *saver;
PrefsWidget *global_prefs_widget;
GladeXML *prefs_widget_data;
xmlNodePtr argument_data;
GScanner *cli_args_db;
GtkWidget *settings_dialog_frame;
GtkWidget *description;
GtkWidget *cli_entry;
GtkWidget *visual_combo;
GtkWidget *name_entry;
GtkWidget *basic_widget;
};
struct _ScreensaverPrefsDialogClass
{
GnomeDialogClass gnome_dialog_class;
void (*ok_clicked) (ScreensaverPrefsDialog *);
void (*demo) (ScreensaverPrefsDialog *);
};
guint screensaver_prefs_dialog_get_type (void);
GtkWidget *screensaver_prefs_dialog_new (Screensaver *saver);
#endif /* __SCREENSAVER_PREFS_DIALOG_H */

View File

@@ -1,44 +0,0 @@
[Desktop Entry]
Name=Screensaver
Name[da]=Pauseskærm
Name[ca]=Protector de pantalla
Name[de]=Bildschirmschoner
Name[es]=Propiedades Salvapantallas
Name[et]=Ekraanisäästja
Name[fi]=Ruudunsäästäjä
Name[fr]=Propriétés Économiseur d'écran
Name[hu]=Képernyõvédõ
Name[it]=Salvaschermo
Name[ja]=¥¹¥¯¥ê¡¼¥ó¥»¡¼¥Ð¡¼
Name[ko]=È­¸é º¸È£±â
Name[no]=Skjermsparer
Name[pl]=Wygaszacz ekranu
Name[pt]=Propriedades da protecção de ecrã
Name[pt_BR]=Propriedades da proteção de tela
Name[ru]=èÒÁÎÉÔÅÌØ ÜËÒÁÎÁ
Name[sv]=Skärmsläckare
Name[uk]=úÂÅÒ¦ÇÁÞ ÅËÒÁÎÁ
Name[wa]=Spårgneu di waitroûle
Comment=Configure the settings of the screensaver.
Comment[da]=Indstil pauseskærmen
Comment[ca]=Configurar el protector de pantalla.
Comment[de]=Bildschirmschoner einrichten
Comment[es]=Configurar el salvapantalla
Comment[et]=Ekraanisäästja häälestus
Comment[fi]=Aseta ruudunsäästäjän asetukset.
Comment[fr]=Configurer l'économiseur d'écran
Comment[hu]=Képernyõvédõ beállítások
Comment[it]=Impostazioni del salvaschermo
Comment[ja]=¥¹¥¯¥ê¡¼¥ó¥»¡¼¥Ð¡¼¤ÎÀßÄê
Comment[ko]=È­¸é º¸È£±â ¼³Á¤
Comment[no]=Endre innstillingene for skjermspareren
Comment[pl]=Konfiguracja wygaszacza ekranu
Comment[pt]=Configura as opções da protecção de ecrã.
Comment[ru]=îÁÓÔÒÏÊËÁ ÈÒÁÎÉÔÅÌÑ ÜËÒÁÎÁ.
Comment[sv]=Ändra inställningar för skärmsläckare
Comment[uk]=îÁÌÁÇÏÄÖÅÎÎÑ ÚÂÅÒ¦ÇÁÞÁ ÅËÒÁÎÁ
Comment[wa]=Apontiaedje do spårgneu di waitroûle
Exec=screensaver-properties-capplet
Icon=gnome-ccscreensaver.png
Terminal=0
Type=Application

View File

@@ -1,4 +0,0 @@
Screensaversdir = $(datadir)/screensavers
Screensavers_DATA = \
hacks.xml \
qix-settings.glade

View File

@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<screensaver-descriptions>
<hack name="attraction">
<command arg="-root"/>
<select id="mode">
<option id="balls" arg-set="-mode balls"/>
<option id="lines" arg-set="-mode lines" test="mode = lines"/>
<option id="tails" arg-set="-mode tails" test="mode = tails"/>
<option id="polygons" arg-set="-mode polygons" test="mode = polygons"/>
<option id="splines" arg-set="-mode splines" test="mode = splines"/>
</select>
<number id="threshold" arg="-threshold %d"/>
<number id="segments" arg="-segments %d"/>
<number id="speed" arg="-delay %d" from-cli-conv="20000 - var" to-cli-conv="20000 - var"/>
<select id="use_color">
<option id="color" enable="number_colors_label,number_colors_widget,color_contrast_label,color_contrast_low_label,color_contrast_high_label,color_contrast_widget"/>
<option id="mono" arg-set="-mono" test="mono"/>
</select>
<number id="number_colors" arg="-colors %d"/>
<number id="color_contrast" arg="-color-shift %d"/>
</hack>
<hack name="qix">
<command arg="-root"/>
<select id="shape">
<option id="lines" enable="trail_type_widget,width_widget,width_label,width_high_label,width_low_label" arg-set="-poly 2"/>
<option id="poly" enable="no_pts_widget,no_pts_label" test="poly > 2"/>
</select>
<number id="no_pts" arg="-poly %d"/>
<select id="trail_type">
<option id="discrete" enable="spread_widget,spread_label,spread_low_label,spread_high_label"/>
<option id="solid" arg-set="-solid" test="solid and not (transparent or xor)"/>
<option id="transparent" arg-set="-solid -transparent" test="solid and transparent"/>
<option id="xor" arg-set="-solid -xor" test="solid and xor"/>
</select>
<boolean id="gravity" arg-set="-gravity" test="gravity"/>
<number id="speed" arg="-delay %d" from-cli-conv="20000 - var" to-cli-conv="20000 - var"/>
<number id="length" arg="-segments %d"/>
<number id="width" arg="-size %d"/>
<number id="count" arg="-count %d"/>
<number id="spread" arg="-spread %d"/>
<select id="use_color">
<option id="color" enable="shift_widget,shift_label,shift_low_label,shift_high_label"/>
<option id="mono" arg-set="-mono" test="mono"/>
</select>
<number id="shift" arg="-color-shift %d"/>
</hack>
</screensaver-descriptions>

View File

@@ -1,839 +0,0 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Screensaver-properties-capplet</name>
<program_name>screensaver-properties-capplet</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
</project>
<widget>
<class>GtkWindow</class>
<name>window</name>
<title>window1</title>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>True</allow_grow>
<auto_shrink>False</auto_shrink>
<widget>
<class>GtkTable</class>
<name>widget</name>
<border_width>10</border_width>
<rows>7</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<widget>
<class>GtkOptionMenu</class>
<name>shape_widget</name>
<can_focus>True</can_focus>
<items>Lines
Polygons
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkTable</class>
<name>table2</name>
<rows>8</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkHScale</class>
<name>speed_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>10000</value>
<lower>0</lower>
<upper>20000</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>length_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>50</value>
<lower>0</lower>
<upper>1000</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>width_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>100</value>
<lower>0</lower>
<upper>1000</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label21</name>
<label>Speed</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>width_label</name>
<label>Width</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label22</name>
<label>Length</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>width_low_label</name>
<label>Narrow</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>width_high_label</name>
<label>Wide</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label18</name>
<label>Long</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label16</name>
<label>Fast</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label15</name>
<label>Slow</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label17</name>
<label>Short</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>3</top_attach>
<bottom_attach>4</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>spread_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>8</value>
<lower>0</lower>
<upper>30</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>7</top_attach>
<bottom_attach>8</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>spread_label</name>
<label>Spread between lines</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>6</top_attach>
<bottom_attach>7</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>spread_low_label</name>
<label>Short</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>7</top_attach>
<bottom_attach>8</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>spread_high_label</name>
<label>Long</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>7</top_attach>
<bottom_attach>8</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<name>no_pts_label</name>
<label>Number of points:</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Number of trails:</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>2</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkCheckButton</class>
<name>gravity_widget</name>
<can_focus>True</can_focus>
<label>Trails attract each other</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>2</top_attach>
<bottom_attach>3</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkTable</class>
<name>table3</name>
<rows>2</rows>
<columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>5</row_spacing>
<column_spacing>5</column_spacing>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>6</top_attach>
<bottom_attach>7</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>True</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
<widget>
<class>GtkLabel</class>
<name>shift_low_label</name>
<label>Low</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>shift_high_label</name>
<label>High</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>False</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>shift_label</name>
<label>Color contrast</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<wrap>False</wrap>
<xalign>0</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkHScale</class>
<name>shift_widget</name>
<can_focus>True</can_focus>
<draw_value>False</draw_value>
<value_pos>GTK_POS_TOP</value_pos>
<digits>1</digits>
<policy>GTK_UPDATE_CONTINUOUS</policy>
<value>8.4</value>
<lower>0</lower>
<upper>25</upper>
<step>0</step>
<page>0</page>
<page_size>0</page_size>
<child>
<left_attach>1</left_attach>
<right_attach>2</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>True</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>True</yfill>
</child>
</widget>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>use_color_widget</name>
<can_focus>True</can_focus>
<items>Full Color
Monochrome
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>5</top_attach>
<bottom_attach>6</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkOptionMenu</class>
<name>trail_type_widget</name>
<can_focus>True</can_focus>
<items>Discrete Lines
Solid Trails
Transparent Trails
XOR Trails
</items>
<initial_choice>0</initial_choice>
<child>
<left_attach>0</left_attach>
<right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkSpinButton</class>
<name>count_widget</name>
<can_focus>True</can_focus>
<climb_rate>1</climb_rate>
<digits>0</digits>
<numeric>False</numeric>
<update_policy>GTK_UPDATE_ALWAYS</update_policy>
<snap>False</snap>
<wrap>False</wrap>
<value>1</value>
<lower>0</lower>
<upper>100</upper>
<step>1</step>
<page>10</page>
<page_size>10</page_size>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>4</top_attach>
<bottom_attach>5</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
<widget>
<class>GtkSpinButton</class>
<name>no_pts_widget</name>
<can_focus>True</can_focus>
<climb_rate>1</climb_rate>
<digits>0</digits>
<numeric>False</numeric>
<update_policy>GTK_UPDATE_ALWAYS</update_policy>
<snap>False</snap>
<wrap>False</wrap>
<value>3</value>
<lower>3</lower>
<upper>100</upper>
<step>1</step>
<page>10</page>
<page_size>10</page_size>
<child>
<left_attach>2</left_attach>
<right_attach>3</right_attach>
<top_attach>0</top_attach>
<bottom_attach>1</bottom_attach>
<xpad>0</xpad>
<ypad>0</ypad>
<xexpand>False</xexpand>
<yexpand>False</yexpand>
<xshrink>False</xshrink>
<yshrink>False</yshrink>
<xfill>True</xfill>
<yfill>False</yfill>
</child>
</widget>
</widget>
</widget>
</GTK-Interface>

View File

@@ -1,239 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* selection-dialog.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <ctype.h>
#include <gnome.h>
#include <parser.h>
#include "selection-dialog.h"
#include "preferences.h"
enum {
OK_CLICKED_SIGNAL,
LAST_SIGNAL
};
static xmlDocPtr screensaver_doc;
static gint selection_dialog_signals[LAST_SIGNAL] = { 0 };
static void selection_dialog_init (SelectionDialog *dialog);
static void selection_dialog_class_init (SelectionDialogClass *dialog);
static void place_screensaver_list (SelectionDialog *dialog);
static void select_program_cb (GtkListItem *item,
SelectionDialog *dialog);
static void selection_dialog_ok_cb (GtkWidget *widget,
SelectionDialog *dialog);
static void selection_dialog_cancel_cb (GtkWidget *widget,
SelectionDialog *dialog);
guint
selection_dialog_get_type (void)
{
static guint selection_dialog_type = 0;
if (!selection_dialog_type) {
GtkTypeInfo selection_dialog_info = {
"SelectionDialog",
sizeof (SelectionDialog),
sizeof (SelectionDialogClass),
(GtkClassInitFunc) selection_dialog_class_init,
(GtkObjectInitFunc) selection_dialog_init,
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL
};
selection_dialog_type =
gtk_type_unique (gnome_dialog_get_type (),
&selection_dialog_info);
}
return selection_dialog_type;
}
static void
selection_dialog_init (SelectionDialog *dialog)
{
GtkWidget *label, *scrolled_window, *viewport;
GtkBox *vbox;
gtk_window_set_title (GTK_WINDOW (dialog), _("Add a new screensaver"));
gnome_dialog_append_button (GNOME_DIALOG (dialog),
GNOME_STOCK_BUTTON_OK);
gnome_dialog_append_button (GNOME_DIALOG (dialog),
GNOME_STOCK_BUTTON_CANCEL);
vbox = GTK_BOX (GNOME_DIALOG (dialog)->vbox);
label = gtk_label_new (_("Select the screensaver to run from the list below:"));
gtk_box_pack_start (vbox, label, FALSE, TRUE, 0);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
gtk_box_pack_start (vbox, scrolled_window, TRUE, TRUE, 0);
viewport = gtk_viewport_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled_window), viewport);
dialog->program_list = GTK_LIST (gtk_list_new ());
gtk_list_set_selection_mode (GTK_LIST (dialog->program_list),
GTK_SELECTION_SINGLE);
gtk_container_add (GTK_CONTAINER (viewport),
GTK_WIDGET (dialog->program_list));
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0,
GTK_SIGNAL_FUNC (selection_dialog_ok_cb),
dialog);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 1,
GTK_SIGNAL_FUNC
(selection_dialog_cancel_cb),
dialog);
gtk_widget_show_all (GNOME_DIALOG (dialog)->vbox);
}
static void
selection_dialog_class_init (SelectionDialogClass *class)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass *) class;
selection_dialog_signals[OK_CLICKED_SIGNAL] =
gtk_signal_new ("ok-clicked", GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (SelectionDialogClass,
ok_clicked),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
gtk_object_class_add_signals (object_class,
selection_dialog_signals,
LAST_SIGNAL);
class->ok_clicked = NULL;
}
GtkWidget *
selection_dialog_new (PrefsWidget *prefs_widget)
{
GtkWidget *widget;
widget = gtk_type_new (selection_dialog_get_type ());
if (!screensaver_doc)
screensaver_doc = xmlParseFile (SSPROP_DATADIR "/hacks.xml");
place_screensaver_list (SELECTION_DIALOG (widget));
gtk_widget_show (widget);
return widget;
}
static void
place_screensaver_list (SelectionDialog *dialog)
{
GtkWidget *item;
GList *item_list_head = NULL, *item_list_tail = NULL;
xmlNodePtr node;
gchar *label;
node = xmlDocGetRootElement (screensaver_doc);
if (node) {
node = node->childs;
while (node) {
label = xmlGetProp (node, "name");
label[0] = toupper (label[0]);
item = gtk_list_item_new_with_label (label);
gtk_widget_show (item);
gtk_object_set_data (GTK_OBJECT (item), "node", node);
gtk_signal_connect (GTK_OBJECT (item), "select",
GTK_SIGNAL_FUNC
(select_program_cb),
dialog);
item_list_tail = g_list_append (item_list_tail, item);
if (!item_list_head) item_list_head = item_list_tail;
item_list_tail = g_list_last (item_list_tail);
node = node->next;
}
}
item = gtk_list_item_new_with_label ("Custom");
gtk_widget_show (item);
gtk_signal_connect (GTK_OBJECT (item), "select",
GTK_SIGNAL_FUNC (select_program_cb), dialog);
item_list_tail = g_list_append (item_list_tail, item);
if (!item_list_head) item_list_head = item_list_tail;
gtk_list_append_items (dialog->program_list, item_list_head);
gtk_list_select_item (dialog->program_list, 0);
}
static void
select_program_cb (GtkListItem *item, SelectionDialog *dialog)
{
dialog->selected_program_item = item;
dialog->selected_program_node =
gtk_object_get_data (GTK_OBJECT (item), "node");
}
static void
selection_dialog_ok_cb (GtkWidget *widget, SelectionDialog *dialog)
{
Screensaver *saver;
saver = screensaver_new ();
saver->label = g_strdup (_("New screensaver"));
if (dialog->selected_program_node) {
saver->name =
g_strdup (xmlGetProp (dialog->selected_program_node,
"name"));
saver->command_line = g_strconcat (saver->name, " -root", NULL);
}
gtk_signal_emit (GTK_OBJECT (dialog),
selection_dialog_signals[OK_CLICKED_SIGNAL], saver);
gnome_dialog_close (GNOME_DIALOG (dialog));
}
static void
selection_dialog_cancel_cb (GtkWidget *widget, SelectionDialog *dialog)
{
gnome_dialog_close (GNOME_DIALOG (dialog));
}

View File

@@ -1,61 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* selection-dialog.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen <hovinen@helixcode.com>
* Parts written by Jamie Zawinski <jwz@jwz.org>
*
* 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.
*/
#ifndef __SELECTION_DIALOG_H
#define __SELECTION_DIALOG_H
#include <gnome.h>
#include <tree.h>
#include "prefs-widget.h"
#define SELECTION_DIALOG(obj) GTK_CHECK_CAST (obj, selection_dialog_get_type (), SelectionDialog)
#define SELECTION_DIALOG_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, selection_dialog_get_type (), SelectionDialogClass)
#define IS_SELECTION_DIALOG(obj) GTK_CHECK_TYPE (obj, selection_dialog_get_type ())
typedef struct _SelectionDialog SelectionDialog;
typedef struct _SelectionDialogClass SelectionDialogClass;
struct _SelectionDialog
{
GnomeDialog gnome_dialog;
GtkList *program_list;
GtkListItem *selected_program_item;
xmlNodePtr selected_program_node;
};
struct _SelectionDialogClass
{
GnomeDialogClass gnome_dialog_class;
void (*ok_clicked) (SelectionDialog *, Screensaver *);
};
guint selection_dialog_get_type (void);
GtkWidget *selection_dialog_new (PrefsWidget *prefs_widget);
#endif /* __SELECTION_DIALOG_H */

View File

@@ -1,22 +0,0 @@
/* XPM */
static char * unchecked_disabled_xpm[] = {
"16 16 3 2",
" g None",
". g #000000",
"+ g #D9D9D9",
" ",
" ",
" . . . . . . . . . . . . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . . . . . . . . . . . . ",
" ",
" "};

View File

@@ -1,22 +0,0 @@
/* XPM */
static char * unchecked_xpm[] = {
"16 16 3 2",
" g None",
". g #000000",
"+ g #FFFFFF",
" ",
" ",
" . . . . . . . . . . . . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . + + + + + + + + + + . ",
" . . . . . . . . . . . . ",
" ",
" "};

View File

@@ -1,5 +0,0 @@
Makefile.in
Makefile
.deps
.libs
theme-selector-capplet

View File

@@ -1,34 +0,0 @@
INCLUDES = -I. -I$(srcdir) \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(srcdir)/../../control-center \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) $(GNOME_INCLUDEDIR)
bin_PROGRAMS = theme-selector-capplet
theme_selector_capplet_SOURCES = \
da.h \
file.c \
globals.c \
lister.c \
main.c \
signals.c \
demo.c \
gui.c \
install.c
theme_selector_capplet_LDFLAGS = ../../control-center/libcapplet.la `imlib-config --libs`
theme_selector_capplet_LDADD = ../../control-center/libcapplet.la \
$(GNOME_LIBS) $(ORBIT_LIBS) \
$(GNOMEUI_LIBS) $(INTLLIBS) \
-lImlib $(OAF_LIBS) $(GCONF_LIBS)
EXTRA_DIST = \
theme-selector.desktop
sysdir = $(datadir)/control-center/Desktop
sys_DATA = theme-selector.desktop
install-data-local:
$(INSTALL_DATA) $(srcdir)/theme-selector.desktop $(DESTDIR)$(datadir)/gnome/apps/Settings/Desktop/theme-selector.desktop

View File

@@ -1,85 +0,0 @@
#include <gnome.h>
#include <gtk-xmhtml/gtk-xmhtml.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <sys/types.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <limits.h>
#include <fcntl.h>
typedef struct _theme_entry
{
gchar *name;
gchar *rc;
gchar *dir;
gchar *readme;
gchar *icon;
} ThemeEntry;
void md(char *s);
int exists(char *s);
int isfile(char *s);
int isdir(char *s);
char **ls(char *dir, int *num);
void freestrlist(char **l, int num);
void rm(char *s);
void mv(char *s, char *ss);
void cp(char *s, char *ss);
unsigned long moddate(char *s);
int filesize(char *s);
void cd(char *s);
char *cwd(void);
int permissions(char *s);
int owner(char *s);
int group(char *s);
char *username(int uid);
char *homedir(int uid);
char *usershell(int uid);
char *atword(char *s, int num);
char *atchar(char *s, char c);
void word(char *s, int num, char *wd);
int canread(char *s);
int canwrite(char *s);
int canexec(char *s);
char *fileof(char *s);
char *fullfileof(char *s);
char *noext(char *s);
void mkdirs(char *s);
void
free_theme_list(ThemeEntry *list, gint number);
ThemeEntry *
list_themes(gchar *dir, gint *number);
ThemeEntry *
list_system_themes(gint *number);
ThemeEntry *
list_user_themes(gint *number);
GtkWidget *
make_main(void);
void
update_theme_entries(GtkWidget *disp_list);
void
signal_apply_theme(GtkWidget *widget);
void
edit_file_to_use(gchar *file, gchar *theme, gchar *font);
void
set_tmp_rc(void);
void
use_theme(gchar *theme, gchar *font);
void
test_theme(gchar *theme, gchar *font);
gchar *
install_theme(gchar *file);
gint
do_demo(int argc, char **argv);
void
send_socket(void);
void
send_reread(void);
extern GtkWidget *preview_socket;
extern gint prog_fd;
extern gchar gtkrc_tmp[1024];

View File

@@ -1,85 +0,0 @@
#include <gnome.h>
#include <gtk-xmhtml/gtk-xmhtml.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <sys/types.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <limits.h>
#include <fcntl.h>
typedef struct _theme_entry
{
gchar *name;
gchar *rc;
gchar *dir;
gchar *readme;
gchar *icon;
} ThemeEntry;
void md(char *s);
int exists(char *s);
int isfile(char *s);
int isdir(char *s);
char **ls(char *dir, int *num);
void freestrlist(char **l, int num);
void rm(char *s);
void mv(char *s, char *ss);
void cp(char *s, char *ss);
unsigned long moddate(char *s);
int filesize(char *s);
void cd(char *s);
char *cwd(void);
int permissions(char *s);
int owner(char *s);
int group(char *s);
char *username(int uid);
char *homedir(int uid);
char *usershell(int uid);
char *atword(char *s, int num);
char *atchar(char *s, char c);
void word(char *s, int num, char *wd);
int canread(char *s);
int canwrite(char *s);
int canexec(char *s);
char *fileof(char *s);
char *fullfileof(char *s);
char *noext(char *s);
void mkdirs(char *s);
void
free_theme_list(ThemeEntry *list, gint number);
ThemeEntry *
list_themes(gchar *dir, gint *number);
ThemeEntry *
list_system_themes(gint *number);
ThemeEntry *
list_user_themes(gint *number);
GtkWidget *
make_main(void);
void
update_theme_entries(GtkWidget *disp_list);
void
signal_apply_theme(GtkWidget *widget);
void
edit_file_to_use(gchar *file, gchar *theme, gchar *font);
void
set_tmp_rc(void);
void
use_theme(gchar *theme, gchar *font);
void
test_theme(gchar *theme, gchar *font);
gchar *
install_theme(gchar *file);
gint
do_demo(int argc, char **argv);
void
send_socket(void);
void
send_reread(void);
extern GtkWidget *preview_socket;
extern gint prog_fd;
extern gchar gtkrc_tmp[1024];

View File

@@ -1,215 +0,0 @@
#include <config.h>
#include "da.h"
#include <errno.h>
GtkWidget *plug;
void
send_socket()
{
gchar buffer[256];
g_snprintf(buffer, sizeof(buffer), "%11lx ",
(gulong)GDK_WINDOW_XWINDOW (preview_socket->window));
write(prog_fd, buffer, strlen(buffer));
}
void
send_reread()
{
gchar buffer[256];
g_snprintf(buffer, sizeof(buffer), "R ");
write(prog_fd, buffer, strlen(buffer));
}
static void
demo_data_in(gpointer data, gint source, GdkInputCondition condition)
{
gchar buf[256];
if (condition & GDK_INPUT_EXCEPTION ||
read(source, buf, 2) == 0)
gtk_main_quit(); /* Parent exited */
else {
if (gtk_rc_reparse_all ())
gtk_widget_reset_rc_styles(plug);
}
}
#define NUM 50
static void
demo_main(int argc, char **argv, gint in_fd)
{
gchar buf[256];
Window window;
GtkWidget *widget, *table, *hbox;
GtkWidget *scrolled_window, *menubar, *menu;
GSList *group;
gchar *titles[2] = {N_("One"),N_("Two")};
/* just 8 short names that will serve as samples for titles in demo */
gchar *row1[2] = {N_("Eenie"), N_("Meenie")};
gchar *row2[2] = {N_("Mynie"), N_("Moe")};
gchar *row3[2] = {N_("Catcha"), N_("Tiger")};
gchar *row4[2] = {N_("By Its"), N_("Toe")};
gchar **rc_files;
gchar **new_rc_files;
gint rc_file_count;
gint new_count;
gchar *home_dir;
gint i;
#ifdef ENABLE_NLS
for (i=0;i<2;i++) {
titles[i]=_(titles[i]);
row1[i]=_(row1[i]);
row2[i]=_(row2[i]);
row3[i]=_(row3[i]);
row4[i]=_(row4[i]);
}
#endif
if (read(in_fd, buf, 12) <= 0)
/* Assume this means that our parent exited or was killed */
exit(0);
buf[12] = 0;
window = strtol (buf, NULL, 16);
fcntl(0, F_SETFL, O_NONBLOCK);
/* Strip out ~/.gtkrc from the set of initial default files.
* to suppress reading of the previous rc file.
*/
rc_files = gtk_rc_get_default_files();
for (rc_file_count = 0; rc_files[rc_file_count]; rc_file_count++)
/* Nothing */;
new_rc_files = g_new (gchar *, rc_file_count + 2);
home_dir = g_get_home_dir();
new_count = 0;
for (i = 0; i<rc_file_count; i++)
{
if (strncmp (rc_files[i], home_dir, strlen (home_dir)) != 0)
new_rc_files[new_count++] = g_strdup (rc_files[i]);
}
new_rc_files[new_count++] = g_strdup (gtkrc_tmp);
new_rc_files[new_count] = NULL;
gtk_rc_set_default_files (new_rc_files);
g_strfreev (new_rc_files);
gtk_set_locale();
gtk_init (&argc, &argv);
plug = gtk_plug_new(window);
table = gtk_table_new (5, 3, FALSE);
gtk_container_add(GTK_CONTAINER(plug), table);
widget = gtk_label_new (_("Selected themes from above will be tested by previewing here."));
gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_LEFT);
gtk_table_attach (GTK_TABLE (table), widget, 0, 3, 0, 1, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
/* column one */
widget = gtk_button_new_with_label (_("Sample Button"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
widget = gtk_check_button_new_with_label (_("Sample Check Button"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0);
widget = gtk_entry_new_with_max_length (50);
gtk_entry_set_text (GTK_ENTRY (widget), _("Sample Text Entry Field"));
gtk_widget_set_usize (widget, 70, -1);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
/* column two */
menubar = gtk_menu_bar_new();
gtk_table_attach (GTK_TABLE (table), menubar, 1, 2, 2, 3, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
widget = gtk_menu_item_new_with_label(_("Submenu"));
gtk_widget_show(widget);
gtk_menu_bar_append(GTK_MENU_BAR(menubar), widget);
gtk_widget_show(menubar);
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), menu);
widget = gtk_menu_item_new_with_label(_("Item 1"));
gtk_widget_show(widget);
gtk_menu_append(GTK_MENU(menu), widget);
widget = gtk_menu_item_new_with_label(_("Another item"));
gtk_widget_show(widget);
gtk_menu_append(GTK_MENU(menu), widget);
widget = gtk_radio_button_new_with_label (NULL, _("Radio Button 1"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget));
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0);
widget = gtk_radio_button_new_with_label (group, _("Radio Button 2"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget));
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 0, 0);
/* column three */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_table_attach (GTK_TABLE (table), scrolled_window, 2, 3, 2, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0);
widget = gtk_clist_new_with_titles (2, titles);
gtk_clist_set_column_width (GTK_CLIST(widget), 0, 45);
gtk_clist_set_column_width (GTK_CLIST(widget), 1, 45);
gtk_clist_append (GTK_CLIST(widget), row1);
gtk_clist_append (GTK_CLIST(widget), row2);
gtk_clist_append (GTK_CLIST(widget), row3);
gtk_clist_append (GTK_CLIST(widget), row4);
gtk_widget_set_usize (widget, 160, -1);
gtk_container_add (GTK_CONTAINER (scrolled_window), widget);
gdk_input_add_full(in_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, demo_data_in, NULL, NULL);
gtk_widget_show_all (plug);
gtk_main ();
}
gint
do_demo(int argc, char **argv)
{
gint toProg[2];
gint pid;
pipe(toProg);
if (!(pid = fork()))
{
close(toProg[1]);
demo_main(argc, argv, toProg[0]);
exit(0);
}
else if (pid > 0)
{
close(toProg[0]);
prog_fd = toProg[1];
return pid;
}
else
{
/* baaaaaaaah eeeeek */
return -1;
}
}

View File

@@ -1,215 +0,0 @@
#include <config.h>
#include "da.h"
#include <errno.h>
GtkWidget *plug;
void
send_socket()
{
gchar buffer[256];
g_snprintf(buffer, sizeof(buffer), "%11lx ",
(gulong)GDK_WINDOW_XWINDOW (preview_socket->window));
write(prog_fd, buffer, strlen(buffer));
}
void
send_reread()
{
gchar buffer[256];
g_snprintf(buffer, sizeof(buffer), "R ");
write(prog_fd, buffer, strlen(buffer));
}
static void
demo_data_in(gpointer data, gint source, GdkInputCondition condition)
{
gchar buf[256];
if (condition & GDK_INPUT_EXCEPTION ||
read(source, buf, 2) == 0)
gtk_main_quit(); /* Parent exited */
else {
if (gtk_rc_reparse_all ())
gtk_widget_reset_rc_styles(plug);
}
}
#define NUM 50
static void
demo_main(int argc, char **argv, gint in_fd)
{
gchar buf[256];
Window window;
GtkWidget *widget, *table, *hbox;
GtkWidget *scrolled_window, *menubar, *menu;
GSList *group;
gchar *titles[2] = {N_("One"),N_("Two")};
/* just 8 short names that will serve as samples for titles in demo */
gchar *row1[2] = {N_("Eenie"), N_("Meenie")};
gchar *row2[2] = {N_("Mynie"), N_("Moe")};
gchar *row3[2] = {N_("Catcha"), N_("Tiger")};
gchar *row4[2] = {N_("By Its"), N_("Toe")};
gchar **rc_files;
gchar **new_rc_files;
gint rc_file_count;
gint new_count;
gchar *home_dir;
gint i;
#ifdef ENABLE_NLS
for (i=0;i<2;i++) {
titles[i]=_(titles[i]);
row1[i]=_(row1[i]);
row2[i]=_(row2[i]);
row3[i]=_(row3[i]);
row4[i]=_(row4[i]);
}
#endif
if (read(in_fd, buf, 12) <= 0)
/* Assume this means that our parent exited or was killed */
exit(0);
buf[12] = 0;
window = strtol (buf, NULL, 16);
fcntl(0, F_SETFL, O_NONBLOCK);
/* Strip out ~/.gtkrc from the set of initial default files.
* to suppress reading of the previous rc file.
*/
rc_files = gtk_rc_get_default_files();
for (rc_file_count = 0; rc_files[rc_file_count]; rc_file_count++)
/* Nothing */;
new_rc_files = g_new (gchar *, rc_file_count + 2);
home_dir = g_get_home_dir();
new_count = 0;
for (i = 0; i<rc_file_count; i++)
{
if (strncmp (rc_files[i], home_dir, strlen (home_dir)) != 0)
new_rc_files[new_count++] = g_strdup (rc_files[i]);
}
new_rc_files[new_count++] = g_strdup (gtkrc_tmp);
new_rc_files[new_count] = NULL;
gtk_rc_set_default_files (new_rc_files);
g_strfreev (new_rc_files);
gtk_set_locale();
gtk_init (&argc, &argv);
plug = gtk_plug_new(window);
table = gtk_table_new (5, 3, FALSE);
gtk_container_add(GTK_CONTAINER(plug), table);
widget = gtk_label_new (_("Selected themes from above will be tested by previewing here."));
gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_LEFT);
gtk_table_attach (GTK_TABLE (table), widget, 0, 3, 0, 1, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
/* column one */
widget = gtk_button_new_with_label (_("Sample Button"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 2, 3, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
widget = gtk_check_button_new_with_label (_("Sample Check Button"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0);
widget = gtk_entry_new_with_max_length (50);
gtk_entry_set_text (GTK_ENTRY (widget), _("Sample Text Entry Field"));
gtk_widget_set_usize (widget, 70, -1);
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
gtk_table_attach (GTK_TABLE (table), hbox, 0, 1, 4, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
/* column two */
menubar = gtk_menu_bar_new();
gtk_table_attach (GTK_TABLE (table), menubar, 1, 2, 2, 3, 0, 0, GNOME_PAD_SMALL, GNOME_PAD_SMALL);
widget = gtk_menu_item_new_with_label(_("Submenu"));
gtk_widget_show(widget);
gtk_menu_bar_append(GTK_MENU_BAR(menubar), widget);
gtk_widget_show(menubar);
menu = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(widget), menu);
widget = gtk_menu_item_new_with_label(_("Item 1"));
gtk_widget_show(widget);
gtk_menu_append(GTK_MENU(menu), widget);
widget = gtk_menu_item_new_with_label(_("Another item"));
gtk_widget_show(widget);
gtk_menu_append(GTK_MENU(menu), widget);
widget = gtk_radio_button_new_with_label (NULL, _("Radio Button 1"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget));
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, 0, 0, 0);
widget = gtk_radio_button_new_with_label (group, _("Radio Button 2"));
hbox = gtk_hbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget));
gtk_table_attach (GTK_TABLE (table), hbox, 1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 0, 0);
/* column three */
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
gtk_table_attach (GTK_TABLE (table), scrolled_window, 2, 3, 2, 5, GTK_EXPAND | GTK_FILL, 0, GNOME_PAD_SMALL, 0);
widget = gtk_clist_new_with_titles (2, titles);
gtk_clist_set_column_width (GTK_CLIST(widget), 0, 45);
gtk_clist_set_column_width (GTK_CLIST(widget), 1, 45);
gtk_clist_append (GTK_CLIST(widget), row1);
gtk_clist_append (GTK_CLIST(widget), row2);
gtk_clist_append (GTK_CLIST(widget), row3);
gtk_clist_append (GTK_CLIST(widget), row4);
gtk_widget_set_usize (widget, 160, -1);
gtk_container_add (GTK_CONTAINER (scrolled_window), widget);
gdk_input_add_full(in_fd, GDK_INPUT_READ | GDK_INPUT_EXCEPTION, demo_data_in, NULL, NULL);
gtk_widget_show_all (plug);
gtk_main ();
}
gint
do_demo(int argc, char **argv)
{
gint toProg[2];
gint pid;
pipe(toProg);
if (!(pid = fork()))
{
close(toProg[1]);
demo_main(argc, argv, toProg[0]);
exit(0);
}
else if (pid > 0)
{
close(toProg[0]);
prog_fd = toProg[1];
return pid;
}
else
{
/* baaaaaaaah eeeeek */
return -1;
}
}

View File

@@ -1,535 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <signal.h>
#include <time.h>
#include <math.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include "da.h"
void
md(char *s)
{
if ((!s) || (!*s))
return;
mkdir(s, S_IRWXU);
}
int
exists(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
return 1;
}
int
isfile(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
if (st.st_blocks == 0)
return 0;
if (S_ISREG(st.st_mode))
return 1;
return 0;
}
int
isdir(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
if (S_ISDIR(st.st_mode))
return 1;
return 0;
}
int
ls_compare_func(const void *a, const void *b)
{
return strcmp(*(char **)a, *(char **)b);
}
char **
ls(char *dir, int *num)
{
int i, dirlen;
DIR *dirp;
char **names;
struct dirent *dp;
if ((!dir) || (!*dir))
return 0;
dirp = opendir(dir);
if (!dirp)
{
*num = 0;
return NULL;
}
/* count # of entries in dir (worst case) */
for (dirlen = 0; (dp = readdir(dirp)) != NULL; dirlen++);
if (!dirlen)
{
closedir(dirp);
*num = dirlen;
return NULL;
}
/* load up the entries, now that we know how many to make */
names = (char **)malloc(dirlen * sizeof(char *));
if (!names)
return NULL;
rewinddir(dirp);
for (i = 0; i < dirlen;)
{
dp = readdir(dirp);
if (!dp)
break;
names[i] = (char *)malloc(strlen(dp->d_name) + 1);
if (!names)
return NULL;
strcpy(names[i], dp->d_name);
i++;
}
if (i < dirlen)
dirlen = i; /* dir got shorter... */
closedir(dirp);
*num = dirlen;
qsort(names, dirlen, sizeof(char *), ls_compare_func);
return names;
}
void
freestrlist(char **l, int num)
{
if (!l)
return;
while (num--)
if (l[num])
free(l[num]);
free(l);
}
void
rm(char *s)
{
if ((!s) || (!*s))
return;
unlink(s);
}
void
mv(char *s, char *ss)
{
if ((!s) || (!ss) || (!*s) || (!*ss))
return;
rename(s, ss);
}
void
cp(char *s, char *ss)
{
int i;
FILE *f, *ff;
unsigned char buf[1];
if ((!s) || (!ss) || (!*s) || (!*ss))
return;
if (!exists(s))
return;
i = filesize(s);
f = fopen(s, "r");
if (!f)
return;
ff = fopen(ss, "w");
if (!ff)
{
fclose(f);
return;
}
while (fread(buf, 1, 1, f))
fwrite(buf, 1, 1, ff);
fclose(f);
fclose(ff);
}
unsigned long
moddate(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
if (st.st_mtime > st.st_ctime)
return st.st_mtime;
else
return st.st_ctime;
}
int
filesize(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
return (int)st.st_size;
}
void
cd(char *s)
{
if ((!s) || (!*s))
return;
chdir(s);
}
char *
cwd(void)
{
char s[4096];
getcwd(s, sizeof(s));
return strdup(s);
}
int
permissions(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
return st.st_mode;
}
int
owner(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
return st.st_uid;
}
int
group(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
return st.st_gid;
}
char *
username(int uid)
{
struct passwd *pass;
char *result;
pass = getpwuid(uid);
if (pass && pass->pw_name)
result = strdup(pass->pw_name);
else
result = NULL;
endpwent();
return result;
}
char *
homedir(int uid)
{
struct passwd *pass;
char *result;
result = getenv("HOME");
if (result)
return strdup(result);
pass = getpwuid(uid);
if (pass && pass->pw_dir)
result = strdup(pass->pw_dir);
else
result = NULL;
endpwent();
return result;
}
char *
usershell(int uid)
{
struct passwd *pass;
char *result;
pass = getpwuid(uid);
if (pass && pass->pw_shell)
result = strdup(pass->pw_shell);
else
result = NULL;
endpwent();
return result;
}
char *
atword(char *s, int num)
{
int cnt, i;
if (!s)
return NULL;
cnt = 0;
i = 0;
while (s[i])
{
if ((s[i] != ' ') && (s[i] != '\t'))
{
if (i == 0)
cnt++;
else if ((s[i - 1] == ' ') || (s[i - 1] == '\t'))
cnt++;
if (cnt == num)
return &s[i];
}
i++;
}
return NULL;
}
char *
atchar(char *s, char c)
{
int i;
if (!s)
return NULL;
i = 0;
while (s[i] != 0)
{
if (s[i] == c)
return &s[i];
i++;
}
return NULL;
}
void
word(char *s, int num, char *wd)
{
int cnt, i;
char *start, *finish, *ss, *w;
if (!s)
return;
if (!wd)
return;
if (num <= 0)
{
*wd = 0;
return;
}
cnt = 0;
i = 0;
start = NULL;
finish = NULL;
ss = NULL;
w = wd;
while (s[i])
{
if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t')))
{
finish = &s[i];
break;
}
if ((s[i] != ' ') && (s[i] != '\t'))
{
if (i == 0)
{
cnt++;
if (cnt == num)
start = &s[i];
}
else if ((s[i - 1] == ' ') || (s[i - 1] == '\t'))
{
cnt++;
if (cnt == num)
start = &s[i];
}
}
i++;
}
if (cnt == num)
{
if ((start) && (finish))
{
for (ss = start; ss < finish; ss++)
*wd++ = *ss;
}
else if (start)
{
for (ss = start; *ss != 0; ss++)
*wd++ = *ss;
}
*wd = 0;
}
return;
}
int
canread(char *s)
{
if ((!s) || (!*s))
return 0;
return access(s, R_OK);
}
int
canwrite(char *s)
{
if ((!s) || (!*s))
return 0;
return access(s, W_OK);
}
int
canexec(char *s)
{
if ((!s) || (!*s))
return 0;
return access(s, X_OK);
}
char *
fileof(char *s)
{
char ss[1024];
int i, p1, p2;
i = 0;
p1 = -1;
p2 = -1;
for (i = strlen(s) - 1; i >= 0; i--)
{
if ((s[i] == '.') && (p2 < 0) && (p1 < 0))
p2 = i;
if ((s[i] == '/') && (p1 < 0))
p1 = i;
}
if (p2 < 0)
p2 = strlen(s);
if (p1 < 0)
p1 = 0;
for (i = 0; i < (p2 - p1 - 1); i++)
ss[i] = s[p1 + 1 + i];
ss[i] = 0;
return strdup(ss);
}
char *
fullfileof(char *s)
{
char ss[1024];
int i, p1, p2;
i = 0;
p1 = -1;
for (i = strlen(s) - 1; i >= 0; i--)
{
if ((s[i] == '/') && (p1 < 0))
p1 = i;
}
p2 = strlen(s);
for (i = 0; i < (p2 - p1 - 1); i++)
ss[i] = s[p1 + 1 + i];
ss[i] = 0;
return strdup(ss);
}
char *
noext(char *s)
{
char ss[1024];
int i, p1, p2;
i = 0;
p1 = -1;
for (i = strlen(s) - 1; i >= 0; i--)
{
if ((s[i] == '/') && (p1 < 0))
break;
else if (s[i] == '.')
{
p1 = i;
break;
}
}
if (p1 < 0)
return strdup(s);
p2 = strlen(s);
for (i = 0; i < p1; i++)
ss[i] = s[i];
ss[i] = 0;
return strdup(ss);
}
void
mkdirs(char *s)
{
char ss[1024];
int i, ii;
i = 0;
ii = 0;
while (s[i])
{
ss[ii++] = s[i];
ss[ii] = 0;
if (s[i] == '/')
{
if (!exists(ss))
md(ss);
else if (!isdir(ss))
return;
}
i++;
}
}

View File

@@ -1,535 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <signal.h>
#include <time.h>
#include <math.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include "da.h"
void
md(char *s)
{
if ((!s) || (!*s))
return;
mkdir(s, S_IRWXU);
}
int
exists(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
return 1;
}
int
isfile(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
if (st.st_blocks == 0)
return 0;
if (S_ISREG(st.st_mode))
return 1;
return 0;
}
int
isdir(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
if (S_ISDIR(st.st_mode))
return 1;
return 0;
}
int
ls_compare_func(const void *a, const void *b)
{
return strcmp(*(char **)a, *(char **)b);
}
char **
ls(char *dir, int *num)
{
int i, dirlen;
DIR *dirp;
char **names;
struct dirent *dp;
if ((!dir) || (!*dir))
return 0;
dirp = opendir(dir);
if (!dirp)
{
*num = 0;
return NULL;
}
/* count # of entries in dir (worst case) */
for (dirlen = 0; (dp = readdir(dirp)) != NULL; dirlen++);
if (!dirlen)
{
closedir(dirp);
*num = dirlen;
return NULL;
}
/* load up the entries, now that we know how many to make */
names = (char **)malloc(dirlen * sizeof(char *));
if (!names)
return NULL;
rewinddir(dirp);
for (i = 0; i < dirlen;)
{
dp = readdir(dirp);
if (!dp)
break;
names[i] = (char *)malloc(strlen(dp->d_name) + 1);
if (!names)
return NULL;
strcpy(names[i], dp->d_name);
i++;
}
if (i < dirlen)
dirlen = i; /* dir got shorter... */
closedir(dirp);
*num = dirlen;
qsort(names, dirlen, sizeof(char *), ls_compare_func);
return names;
}
void
freestrlist(char **l, int num)
{
if (!l)
return;
while (num--)
if (l[num])
free(l[num]);
free(l);
}
void
rm(char *s)
{
if ((!s) || (!*s))
return;
unlink(s);
}
void
mv(char *s, char *ss)
{
if ((!s) || (!ss) || (!*s) || (!*ss))
return;
rename(s, ss);
}
void
cp(char *s, char *ss)
{
int i;
FILE *f, *ff;
unsigned char buf[1];
if ((!s) || (!ss) || (!*s) || (!*ss))
return;
if (!exists(s))
return;
i = filesize(s);
f = fopen(s, "r");
if (!f)
return;
ff = fopen(ss, "w");
if (!ff)
{
fclose(f);
return;
}
while (fread(buf, 1, 1, f))
fwrite(buf, 1, 1, ff);
fclose(f);
fclose(ff);
}
unsigned long
moddate(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
if (st.st_mtime > st.st_ctime)
return st.st_mtime;
else
return st.st_ctime;
}
int
filesize(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (stat(s, &st) < 0)
return 0;
return (int)st.st_size;
}
void
cd(char *s)
{
if ((!s) || (!*s))
return;
chdir(s);
}
char *
cwd(void)
{
char s[4096];
getcwd(s, sizeof(s));
return strdup(s);
}
int
permissions(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
return st.st_mode;
}
int
owner(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
return st.st_uid;
}
int
group(char *s)
{
struct stat st;
if ((!s) || (!*s))
return 0;
if (!stat(s, &st) < 0)
return 0;
return st.st_gid;
}
char *
username(int uid)
{
struct passwd *pass;
char *result;
pass = getpwuid(uid);
if (pass && pass->pw_name)
result = strdup(pass->pw_name);
else
result = NULL;
endpwent();
return result;
}
char *
homedir(int uid)
{
struct passwd *pass;
char *result;
result = getenv("HOME");
if (result)
return strdup(result);
pass = getpwuid(uid);
if (pass && pass->pw_dir)
result = strdup(pass->pw_dir);
else
result = NULL;
endpwent();
return result;
}
char *
usershell(int uid)
{
struct passwd *pass;
char *result;
pass = getpwuid(uid);
if (pass && pass->pw_shell)
result = strdup(pass->pw_shell);
else
result = NULL;
endpwent();
return result;
}
char *
atword(char *s, int num)
{
int cnt, i;
if (!s)
return NULL;
cnt = 0;
i = 0;
while (s[i])
{
if ((s[i] != ' ') && (s[i] != '\t'))
{
if (i == 0)
cnt++;
else if ((s[i - 1] == ' ') || (s[i - 1] == '\t'))
cnt++;
if (cnt == num)
return &s[i];
}
i++;
}
return NULL;
}
char *
atchar(char *s, char c)
{
int i;
if (!s)
return NULL;
i = 0;
while (s[i] != 0)
{
if (s[i] == c)
return &s[i];
i++;
}
return NULL;
}
void
word(char *s, int num, char *wd)
{
int cnt, i;
char *start, *finish, *ss, *w;
if (!s)
return;
if (!wd)
return;
if (num <= 0)
{
*wd = 0;
return;
}
cnt = 0;
i = 0;
start = NULL;
finish = NULL;
ss = NULL;
w = wd;
while (s[i])
{
if ((cnt == num) && ((s[i] == ' ') || (s[i] == '\t')))
{
finish = &s[i];
break;
}
if ((s[i] != ' ') && (s[i] != '\t'))
{
if (i == 0)
{
cnt++;
if (cnt == num)
start = &s[i];
}
else if ((s[i - 1] == ' ') || (s[i - 1] == '\t'))
{
cnt++;
if (cnt == num)
start = &s[i];
}
}
i++;
}
if (cnt == num)
{
if ((start) && (finish))
{
for (ss = start; ss < finish; ss++)
*wd++ = *ss;
}
else if (start)
{
for (ss = start; *ss != 0; ss++)
*wd++ = *ss;
}
*wd = 0;
}
return;
}
int
canread(char *s)
{
if ((!s) || (!*s))
return 0;
return access(s, R_OK);
}
int
canwrite(char *s)
{
if ((!s) || (!*s))
return 0;
return access(s, W_OK);
}
int
canexec(char *s)
{
if ((!s) || (!*s))
return 0;
return access(s, X_OK);
}
char *
fileof(char *s)
{
char ss[1024];
int i, p1, p2;
i = 0;
p1 = -1;
p2 = -1;
for (i = strlen(s) - 1; i >= 0; i--)
{
if ((s[i] == '.') && (p2 < 0) && (p1 < 0))
p2 = i;
if ((s[i] == '/') && (p1 < 0))
p1 = i;
}
if (p2 < 0)
p2 = strlen(s);
if (p1 < 0)
p1 = 0;
for (i = 0; i < (p2 - p1 - 1); i++)
ss[i] = s[p1 + 1 + i];
ss[i] = 0;
return strdup(ss);
}
char *
fullfileof(char *s)
{
char ss[1024];
int i, p1, p2;
i = 0;
p1 = -1;
for (i = strlen(s) - 1; i >= 0; i--)
{
if ((s[i] == '/') && (p1 < 0))
p1 = i;
}
p2 = strlen(s);
for (i = 0; i < (p2 - p1 - 1); i++)
ss[i] = s[p1 + 1 + i];
ss[i] = 0;
return strdup(ss);
}
char *
noext(char *s)
{
char ss[1024];
int i, p1, p2;
i = 0;
p1 = -1;
for (i = strlen(s) - 1; i >= 0; i--)
{
if ((s[i] == '/') && (p1 < 0))
break;
else if (s[i] == '.')
{
p1 = i;
break;
}
}
if (p1 < 0)
return strdup(s);
p2 = strlen(s);
for (i = 0; i < p1; i++)
ss[i] = s[i];
ss[i] = 0;
return strdup(ss);
}
void
mkdirs(char *s)
{
char ss[1024];
int i, ii;
i = 0;
ii = 0;
while (s[i])
{
ss[ii++] = s[i];
ss[ii] = 0;
if (s[i] == '/')
{
if (!exists(ss))
md(ss);
else if (!isdir(ss))
return;
}
i++;
}
}

View File

@@ -1,5 +0,0 @@
#include "da.h"
gint prog_fd;
gchar gtkrc_tmp[1024];
GtkWidget *preview_socket;

View File

@@ -1,5 +0,0 @@
#include "da.h"
gint prog_fd;
gchar gtkrc_tmp[1024];
GtkWidget *preview_socket;

View File

@@ -1,645 +0,0 @@
#include <config.h>
#include "da.h"
#include "capplet-widget.h"
#include <signal.h>
static gboolean ignore_change = FALSE;
static GtkWidget *install_theme_file_sel;
static GtkWidget *capplet_widget;
static GtkWidget *theme_list;
static GtkWidget *auto_preview;
static GtkWidget *current_theme = NULL;
static GtkWidget *current_global_theme = NULL;
static GtkWidget *initial_theme = NULL;
static GtkWidget *last_theme = NULL;
static GtkWidget *font_sel;
static GtkWidget *font_cbox;
static gboolean initial_preview;
/* If this is TRUE, then we use the custom font */
static gboolean initial_font_cbox;
static gchar *initial_font;
static void
click_preview(GtkWidget *widget, gpointer data);
static void
click_try(GtkWidget *widget, gpointer data);
static void
click_help(GtkWidget *widget, gpointer data);
static void
click_ok(GtkWidget *widget, gpointer data);
static void
click_revert(GtkWidget *widget, gpointer data);
static void
click_entry(GtkWidget *widget, gpointer data);
static void
delete_entry(GtkWidget *widget, gpointer data);
static void
auto_callback (GtkWidget *widget, gpointer data)
{
if (ignore_change == FALSE) {
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
}
}
static void
font_callback (GtkWidget *widget, gchar *font, gpointer data)
{
if (ignore_change == FALSE) {
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
}
}
static void
use_theme_font_callback (GtkWidget *widget, gpointer data)
{
if (ignore_change == FALSE) {
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
if (!GTK_TOGGLE_BUTTON (font_cbox)->active)
gtk_widget_set_sensitive (font_sel, FALSE);
else
gtk_widget_set_sensitive (font_sel, TRUE);
}
}
static void
browse_dialog_ok (GtkWidget *widget, gpointer data)
{
GtkWidget *filesel = gtk_widget_get_toplevel (widget);
gchar *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
gchar *error;
error = install_theme (filename);
if (!error)
update_theme_entries (theme_list);
else
{
char *msg = g_strdup_printf (_("Error installing theme:\n'%s'\n%s"),
filename, error);
GtkWidget *msgbox = gnome_message_box_new (msg,
GNOME_MESSAGE_BOX_ERROR,
GNOME_STOCK_BUTTON_OK,
NULL);
gnome_dialog_run (GNOME_DIALOG (msgbox));
g_free (msg);
g_free (error);
}
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
gtk_widget_destroy (filesel);
}
static void
browse_dialog_close (GtkWidget *widget, gpointer data)
{
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
}
static void
browse_dialog_kill (GtkWidget *widget, gpointer data)
{
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
}
static void
install_theme_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
gtk_widget_set_sensitive (widget, FALSE);
install_theme_file_sel = gtk_file_selection_new (_("Select a theme to install"));
gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (install_theme_file_sel));
/* BEGIN UGLINESS. This code is stolen from gnome_dialog_set_parent.
* We want its functionality, but it takes a GnomeDialog as its argument.
* So we copy it )-: */
parent = gtk_widget_get_toplevel (GTK_WIDGET (widget));
/* We'd like to set a transient_for hint here, but it isn't
* worth the bother, since our parent window isn't in this process
*/
if ( gnome_preferences_get_dialog_centered() ) {
/* User wants us to center over parent */
gint x, y, w, h, dialog_x, dialog_y;
if (GTK_WIDGET_VISIBLE(parent)) {
/* Throw out other positioning */
gtk_window_set_position(GTK_WINDOW(install_theme_file_sel),
GTK_WIN_POS_NONE);
gdk_window_get_origin (GTK_WIDGET(parent)->window, &x, &y);
gdk_window_get_size (GTK_WIDGET(parent)->window, &w, &h);
/* The problem here is we don't know how big the dialog is.
So "centered" isn't really true. We'll go with
"kind of more or less on top" */
dialog_x = x + w/4;
dialog_y = y + h/4;
gtk_widget_set_uposition(GTK_WIDGET(install_theme_file_sel),
dialog_x, dialog_y);
}
}
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel)
->ok_button), "clicked",
(GtkSignalFunc) browse_dialog_ok,
widget);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel)->cancel_button),
"clicked",
GTK_SIGNAL_FUNC(browse_dialog_close),
widget);
gtk_signal_connect (GTK_OBJECT (install_theme_file_sel), "destroy",
GTK_SIGNAL_FUNC(browse_dialog_kill),
widget);
if (gtk_grab_get_current ())
gtk_grab_add (install_theme_file_sel);
gtk_widget_show (install_theme_file_sel);
}
static gint
delete_capplet (GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* We don't want the toplevel window destroyed until
* our child exits.
*/
close(prog_fd);
return FALSE;
}
GtkWidget *
make_main(void)
{
void *sw, *label;
GtkWidget *box, *hbox, *hbox2, *vbox;
GtkWidget *frame, *button;
GtkWidget *button_vbox;
gboolean default_used;
capplet_widget = capplet_widget_new();
gtk_container_set_border_width(GTK_CONTAINER(capplet_widget), 5);
box = gtk_vbox_new(FALSE, GNOME_PAD);
hbox = gtk_hbox_new(TRUE, GNOME_PAD);
frame = gtk_frame_new (_("Available Themes"));
hbox2 = gtk_hbox_new(FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox2), GNOME_PAD_SMALL);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbox2);
/* List of available themes
*/
theme_list = gtk_list_new();
gtk_list_set_selection_mode(GTK_LIST(theme_list), GTK_SELECTION_BROWSE);
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), theme_list);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_usize (sw, 120, -1);
gtk_box_pack_start(GTK_BOX(hbox2), sw, TRUE, TRUE, 0);
/* Buttons to preview, and install themes
*/
button_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (button_vbox), GNOME_PAD_SMALL);
gtk_box_pack_start(GTK_BOX(hbox2), button_vbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Auto\nPreview"));
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
auto_preview = gtk_check_button_new ();
initial_preview = gnome_config_get_bool ("/theme-switcher-capplet/settings/auto=TRUE");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview),
initial_preview);
gtk_signal_connect (GTK_OBJECT (auto_preview), "toggled", GTK_SIGNAL_FUNC (auto_callback), NULL);
gtk_container_add (GTK_CONTAINER (auto_preview), label);
gtk_box_pack_start (GTK_BOX (button_vbox), auto_preview, FALSE, FALSE, 0);
button = gtk_button_new_with_label (_("Preview"));
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (click_preview), NULL);
gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label (_("Install new\ntheme..."));
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (install_theme_callback), NULL);
gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
/* Font selector.
*/
frame = gtk_frame_new (_("User Font"));
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
font_sel = gnome_font_picker_new ();
gnome_font_picker_set_mode (GNOME_FONT_PICKER (font_sel),
GNOME_FONT_PICKER_MODE_FONT_INFO);
initial_font = gnome_config_get_string_with_default ("/theme-switcher-capplet/settings/font",&default_used);
if (initial_font == NULL) {
GtkStyle *style;
gtk_widget_ensure_style (frame);
style = gtk_widget_get_style (frame);
if (style->rc_style == NULL) {
/* FIXME - should really get this from X somehow */
/* for now we just assume default gtk font */
initial_font = g_strdup(_("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*"));
} else {
initial_font = style->rc_style->font_name;
}
}
gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel), initial_font);
gnome_font_picker_fi_set_use_font_in_label (GNOME_FONT_PICKER (font_sel),
TRUE,
12);
gnome_font_picker_fi_set_show_size (GNOME_FONT_PICKER (font_sel), FALSE);
gtk_signal_connect (GTK_OBJECT (font_sel),
"font_set",
font_callback,
NULL);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (frame), vbox);
font_cbox = gtk_check_button_new_with_label (_("Use custom font."));
initial_font_cbox = gnome_config_get_bool ("/theme-switcher-capplet/settings/use_theme_font=FALSE");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox),
initial_font_cbox);
gtk_signal_connect (GTK_OBJECT (font_cbox),
"toggled",
GTK_SIGNAL_FUNC (use_theme_font_callback),
NULL);
gtk_box_pack_start (GTK_BOX (vbox), font_cbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), font_sel, FALSE, FALSE, 0);
if (!GTK_TOGGLE_BUTTON (font_cbox)->active)
gtk_widget_set_sensitive (font_sel, FALSE);
else
gtk_widget_set_sensitive (font_sel, TRUE);
gtk_widget_show_all (vbox);
#if 0
readme_display = gtk_xmhtml_new();
gtk_container_add(GTK_CONTAINER(frame2), readme_display) ;
#endif
/* Preview of theme
*/
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
frame = gtk_frame_new (_("Preview"));
gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
preview_socket = gtk_socket_new();
gtk_container_add(GTK_CONTAINER(frame), preview_socket);
update_theme_entries(theme_list);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "help",
GTK_SIGNAL_FUNC (click_help), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "try",
GTK_SIGNAL_FUNC (click_try), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "ok",
GTK_SIGNAL_FUNC (click_ok), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "revert",
GTK_SIGNAL_FUNC (click_revert), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "cancel",
GTK_SIGNAL_FUNC (click_revert), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "delete_event",
GTK_SIGNAL_FUNC (delete_capplet), NULL);
gtk_container_add (GTK_CONTAINER (capplet_widget), box);
last_theme = NULL;
return capplet_widget;
}
static void
click_preview(GtkWidget *widget, gpointer data)
{
gchar *rc;
/* if (current_theme == last_theme)
return;*/
last_theme = current_theme;
if (!current_theme) {
return;
}
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(current_theme), "rc");
if (GTK_TOGGLE_BUTTON (font_cbox)->active)
test_theme(rc,
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)));
else
{
test_theme(rc, NULL);
}
send_reread();
}
static void
click_help(GtkWidget *widget, gpointer data)
{
gchar *tmp;
tmp = gnome_help_file_find_file ("users-guide", "gccdesktop.html#GCCTHEME");
if (tmp) {
gnome_help_goto(0, tmp);
g_free(tmp);
} else {
GtkWidget *mbox;
mbox = gnome_message_box_new(_("No help is available/installed for these settings. Please make sure you\nhave the GNOME User's Guide installed on your system."),
GNOME_MESSAGE_BOX_ERROR,
_("Close"), NULL);
gtk_widget_show(mbox);
}
}
static void
click_try(GtkWidget *widget, gpointer data)
{
gchar *rc;
gchar *dir;
/* if (current_theme == current_global_theme)
return;*/
widget = current_theme;
if (!widget)
return;
current_global_theme = current_theme;
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
dir = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "dir");
/* hack for enlightenment only!!!! */
/* FIXME: restart what ever windowmanager you have! */
/*g_snprintf(cmd, sizeof(cmd), "eesh -e \"restart %s/e\"", dir);*/
/* printf("%s\n", cmd); */
send_reread();
if (GTK_TOGGLE_BUTTON (font_cbox)->active)
{
use_theme(rc,
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)));
}
else
{
use_theme(rc, NULL);
}
gdk_error_warnings = 0;
signal_apply_theme(widget);
gdk_flush();
/* system(cmd); */
gdk_error_warnings = 1;
}
static void
click_ok(GtkWidget *widget, gpointer data)
{
click_try (widget, data);
gnome_config_set_bool ("/theme-switcher-capplet/settings/auto",GTK_TOGGLE_BUTTON (auto_preview)->active);
gnome_config_set_string ("/theme-switcher-capplet/settings/theme", gtk_object_get_data (GTK_OBJECT (current_theme), "name"));
gnome_config_set_bool ("/theme-switcher-capplet/settings/use_theme_font",
GTK_TOGGLE_BUTTON (font_cbox)->active);
gnome_config_set_string ("/theme-switcher-capplet/settings/font",
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)));
gnome_config_sync ();
}
static void
click_revert(GtkWidget *widget, gpointer data)
{
gchar *rc;
widget = initial_theme;
if (!widget)
/* we hope this doesn't happen, but it could if things
* are mis-installed -jrb */
/* Damn, I hate this code... )-: */
return;
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
if ((current_global_theme != initial_theme) ||
(initial_font_cbox != GTK_TOGGLE_BUTTON (font_cbox)->active) ||
(GTK_TOGGLE_BUTTON (font_cbox)->active && strcmp (initial_font,
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)))))
{
/* This if statement is magic to determine if we want to reset the system theme.
* It can almost certainly be cleaned up if needed. Basicly, it sees if anything has
* or if the theme has been set.. */
send_reread();
use_theme(rc, initial_font);
gdk_error_warnings = 0;
signal_apply_theme(widget);
gdk_flush();
gdk_error_warnings = 1;
}
current_global_theme = widget;
ignore_change = TRUE;
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview),
initial_preview);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox),
initial_font_cbox);
if (initial_font)
gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel),
initial_font);
gtk_list_select_child (GTK_LIST (theme_list), initial_theme);
test_theme(rc, initial_font);
send_reread();
if (!GTK_TOGGLE_BUTTON (font_cbox)->active)
gtk_widget_set_sensitive (font_sel, FALSE);
else
gtk_widget_set_sensitive (font_sel, TRUE);
ignore_change = FALSE;
current_theme = initial_theme;
}
static void
click_entry(GtkWidget *widget, gpointer data)
{
gchar *rc, *name;
name = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "name");
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
/* Load in the README file */
#if 0
if (readme_current)
{
g_free(readme_current);
readme_current = NULL;
}
f = fopen(readme, "r");
if (f)
{
GString *new_readme = g_string_new (NULL);
while (fgets(buf, 1024, f))
g_string_append (new_readme, buf);
fclose(f);
gtk_xmhtml_source(GTK_XMHTML(readme_display), new_readme->str);
g_string_free (new_readme, TRUE);
}
else
gtk_xmhtml_source(GTK_XMHTML(readme_display), "");
#endif
if (!ignore_change)
{
current_theme = widget;
if (initial_theme)
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
else
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), FALSE);
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
}
}
static void
delete_entry(GtkWidget *widget, gpointer data)
{
gchar *rc, *name, *icon, *dir;
name = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "name");
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
dir = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "dir");
icon = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "icon");
g_free(name);
g_free(rc);
g_free(dir);
g_free(icon);
if (current_theme == widget)
current_theme = NULL;
}
static gint sort_alpha(const void *a, const void *b)
{
GtkBin *A, *B;
A = GTK_BIN (a);
B = GTK_BIN (b);
return strcmp((char *)GTK_LABEL (A->child)->label, (char *)GTK_LABEL (B->child)->label);
}
void
update_theme_entries(GtkWidget *disp_list)
{
ThemeEntry *te;
gint num;
GList *list;
int i;
GtkWidget *item;
gchar *d_theme = gnome_config_get_string ("/theme-switcher-capplet/settings/theme=Default");
gchar *current_name = NULL;
if (current_theme)
current_name = g_strdup(gtk_object_get_data(GTK_OBJECT(current_theme), "name"));
else
current_name = d_theme;
current_theme = NULL;
initial_theme = NULL;
list = NULL;
gtk_list_clear_items(GTK_LIST(disp_list), 0, -1);
te = list_system_themes(&num);
for (i = 0; i < num; i++)
{
item = gtk_list_item_new_with_label(te[i].name);
gtk_widget_show(item);
if (strcmp (d_theme, te[i].name) == 0)
{
current_global_theme = item;
initial_theme = item;
}
if (current_name && (strcmp (current_name, te[i].name) == 0))
{
current_theme = item;
}
gtk_object_set_data(GTK_OBJECT(item), "name", g_strdup(te[i].name));
gtk_object_set_data(GTK_OBJECT(item), "rc", g_strdup(te[i].rc));
gtk_object_set_data(GTK_OBJECT(item), "dir", g_strdup(te[i].dir));
gtk_object_set_data(GTK_OBJECT(item), "icon", g_strdup(te[i].icon));
gtk_signal_connect(GTK_OBJECT(item), "select",
GTK_SIGNAL_FUNC(click_entry), NULL);
gtk_signal_connect(GTK_OBJECT(item), "destroy",
GTK_SIGNAL_FUNC(delete_entry), NULL);
list = g_list_insert_sorted(list, item, sort_alpha);
}
free_theme_list(te, num);
te = list_user_themes(&num);
for (i = 0; i < num; i++)
{
item = gtk_list_item_new_with_label(te[i].name);
gtk_widget_show(item);
if (strcmp (d_theme, te[i].name) == 0)
initial_theme = item;
if (current_name && (strcmp (current_name, te[i].name) == 0))
current_theme = item;
gtk_object_set_data(GTK_OBJECT(item), "name", g_strdup(te[i].name));
gtk_object_set_data(GTK_OBJECT(item), "rc", g_strdup(te[i].rc));
gtk_object_set_data(GTK_OBJECT(item), "dir", g_strdup(te[i].dir));
gtk_object_set_data(GTK_OBJECT(item), "icon", g_strdup(te[i].icon));
gtk_signal_connect(GTK_OBJECT(item), "select",
GTK_SIGNAL_FUNC(click_entry), NULL);
gtk_signal_connect(GTK_OBJECT(item), "destroy",
GTK_SIGNAL_FUNC(delete_entry), NULL);
list = g_list_insert_sorted(list, item, sort_alpha);
}
free_theme_list(te, num);
/* Suppress an update here, because the BROWSE mode will
* cause a false initial selection
*/
ignore_change = TRUE;
gtk_list_append_items(GTK_LIST(disp_list), list);
ignore_change = FALSE;
if (!current_theme)
current_theme = initial_theme;
/* Suppress an update only if the current theme didn't change or
* this was the first time around
*/
if (current_theme)
{
if (current_name &&
strcmp (gtk_object_get_data(GTK_OBJECT(current_theme), "name"),
current_name) != 0)
{
gtk_list_select_child (GTK_LIST (disp_list), current_theme);
}
else
{
ignore_change = TRUE;
gtk_list_select_child (GTK_LIST (disp_list), current_theme);
ignore_change = FALSE;
}
}
if (current_name != d_theme) {
g_free (current_name);
g_free (d_theme);
} else
g_free (d_theme);
if (current_theme == NULL)
;
}

View File

@@ -1,645 +0,0 @@
#include <config.h>
#include "da.h"
#include "capplet-widget.h"
#include <signal.h>
static gboolean ignore_change = FALSE;
static GtkWidget *install_theme_file_sel;
static GtkWidget *capplet_widget;
static GtkWidget *theme_list;
static GtkWidget *auto_preview;
static GtkWidget *current_theme = NULL;
static GtkWidget *current_global_theme = NULL;
static GtkWidget *initial_theme = NULL;
static GtkWidget *last_theme = NULL;
static GtkWidget *font_sel;
static GtkWidget *font_cbox;
static gboolean initial_preview;
/* If this is TRUE, then we use the custom font */
static gboolean initial_font_cbox;
static gchar *initial_font;
static void
click_preview(GtkWidget *widget, gpointer data);
static void
click_try(GtkWidget *widget, gpointer data);
static void
click_help(GtkWidget *widget, gpointer data);
static void
click_ok(GtkWidget *widget, gpointer data);
static void
click_revert(GtkWidget *widget, gpointer data);
static void
click_entry(GtkWidget *widget, gpointer data);
static void
delete_entry(GtkWidget *widget, gpointer data);
static void
auto_callback (GtkWidget *widget, gpointer data)
{
if (ignore_change == FALSE) {
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
}
}
static void
font_callback (GtkWidget *widget, gchar *font, gpointer data)
{
if (ignore_change == FALSE) {
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
}
}
static void
use_theme_font_callback (GtkWidget *widget, gpointer data)
{
if (ignore_change == FALSE) {
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
if (!GTK_TOGGLE_BUTTON (font_cbox)->active)
gtk_widget_set_sensitive (font_sel, FALSE);
else
gtk_widget_set_sensitive (font_sel, TRUE);
}
}
static void
browse_dialog_ok (GtkWidget *widget, gpointer data)
{
GtkWidget *filesel = gtk_widget_get_toplevel (widget);
gchar *filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel));
gchar *error;
error = install_theme (filename);
if (!error)
update_theme_entries (theme_list);
else
{
char *msg = g_strdup_printf (_("Error installing theme:\n'%s'\n%s"),
filename, error);
GtkWidget *msgbox = gnome_message_box_new (msg,
GNOME_MESSAGE_BOX_ERROR,
GNOME_STOCK_BUTTON_OK,
NULL);
gnome_dialog_run (GNOME_DIALOG (msgbox));
g_free (msg);
g_free (error);
}
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
gtk_widget_destroy (filesel);
}
static void
browse_dialog_close (GtkWidget *widget, gpointer data)
{
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
gtk_widget_destroy (gtk_widget_get_toplevel (widget));
}
static void
browse_dialog_kill (GtkWidget *widget, gpointer data)
{
gtk_widget_set_sensitive (GTK_WIDGET (data), TRUE);
}
static void
install_theme_callback (GtkWidget *widget, gpointer data)
{
GtkWidget *parent;
gtk_widget_set_sensitive (widget, FALSE);
install_theme_file_sel = gtk_file_selection_new (_("Select a theme to install"));
gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (install_theme_file_sel));
/* BEGIN UGLINESS. This code is stolen from gnome_dialog_set_parent.
* We want its functionality, but it takes a GnomeDialog as its argument.
* So we copy it )-: */
parent = gtk_widget_get_toplevel (GTK_WIDGET (widget));
/* We'd like to set a transient_for hint here, but it isn't
* worth the bother, since our parent window isn't in this process
*/
if ( gnome_preferences_get_dialog_centered() ) {
/* User wants us to center over parent */
gint x, y, w, h, dialog_x, dialog_y;
if (GTK_WIDGET_VISIBLE(parent)) {
/* Throw out other positioning */
gtk_window_set_position(GTK_WINDOW(install_theme_file_sel),
GTK_WIN_POS_NONE);
gdk_window_get_origin (GTK_WIDGET(parent)->window, &x, &y);
gdk_window_get_size (GTK_WIDGET(parent)->window, &w, &h);
/* The problem here is we don't know how big the dialog is.
So "centered" isn't really true. We'll go with
"kind of more or less on top" */
dialog_x = x + w/4;
dialog_y = y + h/4;
gtk_widget_set_uposition(GTK_WIDGET(install_theme_file_sel),
dialog_x, dialog_y);
}
}
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel)
->ok_button), "clicked",
(GtkSignalFunc) browse_dialog_ok,
widget);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (install_theme_file_sel)->cancel_button),
"clicked",
GTK_SIGNAL_FUNC(browse_dialog_close),
widget);
gtk_signal_connect (GTK_OBJECT (install_theme_file_sel), "destroy",
GTK_SIGNAL_FUNC(browse_dialog_kill),
widget);
if (gtk_grab_get_current ())
gtk_grab_add (install_theme_file_sel);
gtk_widget_show (install_theme_file_sel);
}
static gint
delete_capplet (GtkWidget *widget, GdkEvent *event, gpointer data)
{
/* We don't want the toplevel window destroyed until
* our child exits.
*/
close(prog_fd);
return FALSE;
}
GtkWidget *
make_main(void)
{
void *sw, *label;
GtkWidget *box, *hbox, *hbox2, *vbox;
GtkWidget *frame, *button;
GtkWidget *button_vbox;
gboolean default_used;
capplet_widget = capplet_widget_new();
gtk_container_set_border_width(GTK_CONTAINER(capplet_widget), 5);
box = gtk_vbox_new(FALSE, GNOME_PAD);
hbox = gtk_hbox_new(TRUE, GNOME_PAD);
frame = gtk_frame_new (_("Available Themes"));
hbox2 = gtk_hbox_new(FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox2), GNOME_PAD_SMALL);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(box), hbox, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbox2);
/* List of available themes
*/
theme_list = gtk_list_new();
gtk_list_set_selection_mode(GTK_LIST(theme_list), GTK_SELECTION_BROWSE);
sw = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), theme_list);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_widget_set_usize (sw, 120, -1);
gtk_box_pack_start(GTK_BOX(hbox2), sw, TRUE, TRUE, 0);
/* Buttons to preview, and install themes
*/
button_vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (button_vbox), GNOME_PAD_SMALL);
gtk_box_pack_start(GTK_BOX(hbox2), button_vbox, FALSE, FALSE, 0);
label = gtk_label_new (_("Auto\nPreview"));
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
auto_preview = gtk_check_button_new ();
initial_preview = gnome_config_get_bool ("/theme-switcher-capplet/settings/auto=TRUE");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview),
initial_preview);
gtk_signal_connect (GTK_OBJECT (auto_preview), "toggled", GTK_SIGNAL_FUNC (auto_callback), NULL);
gtk_container_add (GTK_CONTAINER (auto_preview), label);
gtk_box_pack_start (GTK_BOX (button_vbox), auto_preview, FALSE, FALSE, 0);
button = gtk_button_new_with_label (_("Preview"));
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (click_preview), NULL);
gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label (_("Install new\ntheme..."));
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (install_theme_callback), NULL);
gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
/* Font selector.
*/
frame = gtk_frame_new (_("User Font"));
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
font_sel = gnome_font_picker_new ();
gnome_font_picker_set_mode (GNOME_FONT_PICKER (font_sel),
GNOME_FONT_PICKER_MODE_FONT_INFO);
initial_font = gnome_config_get_string_with_default ("/theme-switcher-capplet/settings/font",&default_used);
if (initial_font == NULL) {
GtkStyle *style;
gtk_widget_ensure_style (frame);
style = gtk_widget_get_style (frame);
if (style->rc_style == NULL) {
/* FIXME - should really get this from X somehow */
/* for now we just assume default gtk font */
initial_font = g_strdup(_("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*"));
} else {
initial_font = style->rc_style->font_name;
}
}
gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel), initial_font);
gnome_font_picker_fi_set_use_font_in_label (GNOME_FONT_PICKER (font_sel),
TRUE,
12);
gnome_font_picker_fi_set_show_size (GNOME_FONT_PICKER (font_sel), FALSE);
gtk_signal_connect (GTK_OBJECT (font_sel),
"font_set",
font_callback,
NULL);
vbox = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (vbox), GNOME_PAD_SMALL);
gtk_container_add (GTK_CONTAINER (frame), vbox);
font_cbox = gtk_check_button_new_with_label (_("Use custom font."));
initial_font_cbox = gnome_config_get_bool ("/theme-switcher-capplet/settings/use_theme_font=FALSE");
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox),
initial_font_cbox);
gtk_signal_connect (GTK_OBJECT (font_cbox),
"toggled",
GTK_SIGNAL_FUNC (use_theme_font_callback),
NULL);
gtk_box_pack_start (GTK_BOX (vbox), font_cbox, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), font_sel, FALSE, FALSE, 0);
if (!GTK_TOGGLE_BUTTON (font_cbox)->active)
gtk_widget_set_sensitive (font_sel, FALSE);
else
gtk_widget_set_sensitive (font_sel, TRUE);
gtk_widget_show_all (vbox);
#if 0
readme_display = gtk_xmhtml_new();
gtk_container_add(GTK_CONTAINER(frame2), readme_display) ;
#endif
/* Preview of theme
*/
hbox = gtk_hbox_new (FALSE, GNOME_PAD_SMALL);
gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD_SMALL);
frame = gtk_frame_new (_("Preview"));
gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
preview_socket = gtk_socket_new();
gtk_container_add(GTK_CONTAINER(frame), preview_socket);
update_theme_entries(theme_list);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "help",
GTK_SIGNAL_FUNC (click_help), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "try",
GTK_SIGNAL_FUNC (click_try), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "ok",
GTK_SIGNAL_FUNC (click_ok), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "revert",
GTK_SIGNAL_FUNC (click_revert), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "cancel",
GTK_SIGNAL_FUNC (click_revert), NULL);
gtk_signal_connect (GTK_OBJECT (capplet_widget), "delete_event",
GTK_SIGNAL_FUNC (delete_capplet), NULL);
gtk_container_add (GTK_CONTAINER (capplet_widget), box);
last_theme = NULL;
return capplet_widget;
}
static void
click_preview(GtkWidget *widget, gpointer data)
{
gchar *rc;
/* if (current_theme == last_theme)
return;*/
last_theme = current_theme;
if (!current_theme) {
return;
}
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(current_theme), "rc");
if (GTK_TOGGLE_BUTTON (font_cbox)->active)
test_theme(rc,
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)));
else
{
test_theme(rc, NULL);
}
send_reread();
}
static void
click_help(GtkWidget *widget, gpointer data)
{
gchar *tmp;
tmp = gnome_help_file_find_file ("users-guide", "gccdesktop.html#GCCTHEME");
if (tmp) {
gnome_help_goto(0, tmp);
g_free(tmp);
} else {
GtkWidget *mbox;
mbox = gnome_message_box_new(_("No help is available/installed for these settings. Please make sure you\nhave the GNOME User's Guide installed on your system."),
GNOME_MESSAGE_BOX_ERROR,
_("Close"), NULL);
gtk_widget_show(mbox);
}
}
static void
click_try(GtkWidget *widget, gpointer data)
{
gchar *rc;
gchar *dir;
/* if (current_theme == current_global_theme)
return;*/
widget = current_theme;
if (!widget)
return;
current_global_theme = current_theme;
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
dir = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "dir");
/* hack for enlightenment only!!!! */
/* FIXME: restart what ever windowmanager you have! */
/*g_snprintf(cmd, sizeof(cmd), "eesh -e \"restart %s/e\"", dir);*/
/* printf("%s\n", cmd); */
send_reread();
if (GTK_TOGGLE_BUTTON (font_cbox)->active)
{
use_theme(rc,
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)));
}
else
{
use_theme(rc, NULL);
}
gdk_error_warnings = 0;
signal_apply_theme(widget);
gdk_flush();
/* system(cmd); */
gdk_error_warnings = 1;
}
static void
click_ok(GtkWidget *widget, gpointer data)
{
click_try (widget, data);
gnome_config_set_bool ("/theme-switcher-capplet/settings/auto",GTK_TOGGLE_BUTTON (auto_preview)->active);
gnome_config_set_string ("/theme-switcher-capplet/settings/theme", gtk_object_get_data (GTK_OBJECT (current_theme), "name"));
gnome_config_set_bool ("/theme-switcher-capplet/settings/use_theme_font",
GTK_TOGGLE_BUTTON (font_cbox)->active);
gnome_config_set_string ("/theme-switcher-capplet/settings/font",
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)));
gnome_config_sync ();
}
static void
click_revert(GtkWidget *widget, gpointer data)
{
gchar *rc;
widget = initial_theme;
if (!widget)
/* we hope this doesn't happen, but it could if things
* are mis-installed -jrb */
/* Damn, I hate this code... )-: */
return;
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
if ((current_global_theme != initial_theme) ||
(initial_font_cbox != GTK_TOGGLE_BUTTON (font_cbox)->active) ||
(GTK_TOGGLE_BUTTON (font_cbox)->active && strcmp (initial_font,
gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_sel)))))
{
/* This if statement is magic to determine if we want to reset the system theme.
* It can almost certainly be cleaned up if needed. Basicly, it sees if anything has
* or if the theme has been set.. */
send_reread();
use_theme(rc, initial_font);
gdk_error_warnings = 0;
signal_apply_theme(widget);
gdk_flush();
gdk_error_warnings = 1;
}
current_global_theme = widget;
ignore_change = TRUE;
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (auto_preview),
initial_preview);
gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (font_cbox),
initial_font_cbox);
if (initial_font)
gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_sel),
initial_font);
gtk_list_select_child (GTK_LIST (theme_list), initial_theme);
test_theme(rc, initial_font);
send_reread();
if (!GTK_TOGGLE_BUTTON (font_cbox)->active)
gtk_widget_set_sensitive (font_sel, FALSE);
else
gtk_widget_set_sensitive (font_sel, TRUE);
ignore_change = FALSE;
current_theme = initial_theme;
}
static void
click_entry(GtkWidget *widget, gpointer data)
{
gchar *rc, *name;
name = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "name");
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
/* Load in the README file */
#if 0
if (readme_current)
{
g_free(readme_current);
readme_current = NULL;
}
f = fopen(readme, "r");
if (f)
{
GString *new_readme = g_string_new (NULL);
while (fgets(buf, 1024, f))
g_string_append (new_readme, buf);
fclose(f);
gtk_xmhtml_source(GTK_XMHTML(readme_display), new_readme->str);
g_string_free (new_readme, TRUE);
}
else
gtk_xmhtml_source(GTK_XMHTML(readme_display), "");
#endif
if (!ignore_change)
{
current_theme = widget;
if (initial_theme)
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), TRUE);
else
capplet_widget_state_changed(CAPPLET_WIDGET (capplet_widget), FALSE);
if (GTK_TOGGLE_BUTTON (auto_preview)->active)
click_preview (widget,NULL);
}
}
static void
delete_entry(GtkWidget *widget, gpointer data)
{
gchar *rc, *name, *icon, *dir;
name = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "name");
rc = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "rc");
dir = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "dir");
icon = (gchar *)gtk_object_get_data(GTK_OBJECT(widget), "icon");
g_free(name);
g_free(rc);
g_free(dir);
g_free(icon);
if (current_theme == widget)
current_theme = NULL;
}
static gint sort_alpha(const void *a, const void *b)
{
GtkBin *A, *B;
A = GTK_BIN (a);
B = GTK_BIN (b);
return strcmp((char *)GTK_LABEL (A->child)->label, (char *)GTK_LABEL (B->child)->label);
}
void
update_theme_entries(GtkWidget *disp_list)
{
ThemeEntry *te;
gint num;
GList *list;
int i;
GtkWidget *item;
gchar *d_theme = gnome_config_get_string ("/theme-switcher-capplet/settings/theme=Default");
gchar *current_name = NULL;
if (current_theme)
current_name = g_strdup(gtk_object_get_data(GTK_OBJECT(current_theme), "name"));
else
current_name = d_theme;
current_theme = NULL;
initial_theme = NULL;
list = NULL;
gtk_list_clear_items(GTK_LIST(disp_list), 0, -1);
te = list_system_themes(&num);
for (i = 0; i < num; i++)
{
item = gtk_list_item_new_with_label(te[i].name);
gtk_widget_show(item);
if (strcmp (d_theme, te[i].name) == 0)
{
current_global_theme = item;
initial_theme = item;
}
if (current_name && (strcmp (current_name, te[i].name) == 0))
{
current_theme = item;
}
gtk_object_set_data(GTK_OBJECT(item), "name", g_strdup(te[i].name));
gtk_object_set_data(GTK_OBJECT(item), "rc", g_strdup(te[i].rc));
gtk_object_set_data(GTK_OBJECT(item), "dir", g_strdup(te[i].dir));
gtk_object_set_data(GTK_OBJECT(item), "icon", g_strdup(te[i].icon));
gtk_signal_connect(GTK_OBJECT(item), "select",
GTK_SIGNAL_FUNC(click_entry), NULL);
gtk_signal_connect(GTK_OBJECT(item), "destroy",
GTK_SIGNAL_FUNC(delete_entry), NULL);
list = g_list_insert_sorted(list, item, sort_alpha);
}
free_theme_list(te, num);
te = list_user_themes(&num);
for (i = 0; i < num; i++)
{
item = gtk_list_item_new_with_label(te[i].name);
gtk_widget_show(item);
if (strcmp (d_theme, te[i].name) == 0)
initial_theme = item;
if (current_name && (strcmp (current_name, te[i].name) == 0))
current_theme = item;
gtk_object_set_data(GTK_OBJECT(item), "name", g_strdup(te[i].name));
gtk_object_set_data(GTK_OBJECT(item), "rc", g_strdup(te[i].rc));
gtk_object_set_data(GTK_OBJECT(item), "dir", g_strdup(te[i].dir));
gtk_object_set_data(GTK_OBJECT(item), "icon", g_strdup(te[i].icon));
gtk_signal_connect(GTK_OBJECT(item), "select",
GTK_SIGNAL_FUNC(click_entry), NULL);
gtk_signal_connect(GTK_OBJECT(item), "destroy",
GTK_SIGNAL_FUNC(delete_entry), NULL);
list = g_list_insert_sorted(list, item, sort_alpha);
}
free_theme_list(te, num);
/* Suppress an update here, because the BROWSE mode will
* cause a false initial selection
*/
ignore_change = TRUE;
gtk_list_append_items(GTK_LIST(disp_list), list);
ignore_change = FALSE;
if (!current_theme)
current_theme = initial_theme;
/* Suppress an update only if the current theme didn't change or
* this was the first time around
*/
if (current_theme)
{
if (current_name &&
strcmp (gtk_object_get_data(GTK_OBJECT(current_theme), "name"),
current_name) != 0)
{
gtk_list_select_child (GTK_LIST (disp_list), current_theme);
}
else
{
ignore_change = TRUE;
gtk_list_select_child (GTK_LIST (disp_list), current_theme);
ignore_change = FALSE;
}
}
if (current_name != d_theme) {
g_free (current_name);
g_free (d_theme);
} else
g_free (d_theme);
if (current_theme == NULL)
;
}

View File

@@ -1,77 +0,0 @@
#include "da.h"
#include <errno.h>
gchar *
install_theme(gchar *file)
{
gchar s[4096];
gchar th[4096];
FILE *f;
guchar buf[1024];
gchar *theme_dir;
gchar *home;
if (isdir(file))
return FALSE;
theme_dir = gtk_rc_get_theme_dir();
if (geteuid() == 0)
g_snprintf(th, sizeof(th), "%s/", theme_dir);
else
{
home = g_get_home_dir();
if (!home)
{
g_free(theme_dir);
return g_strdup(_("Home directory doesn't exist!\n"));
}
g_snprintf(th, sizeof(th), "%s/.themes/", home);
}
g_free(theme_dir);
if (!isdir(th))
md(th);
if (!isfile(file))
return g_strdup(_("Theme does not exist"));
f = fopen(file, "r");
if (f)
{
fread(buf, 1, 1000, f);
fclose(f);
if ((buf[0] == 31) && (buf[1] == 139))
{
/*gzipped tarball */
/*sprintf(s,"gzip -d -c < %s | tar -xf - -C %s",Theme_Tar_Ball,Theme_Path); */
g_snprintf(s, sizeof(s),
"gzip -d -c < %s | (cd %s ; tar -xf -)",
file, th);
}
else if ((buf[257] == 'u') && (buf[258] == 's') && (buf[259] == 't') &&
(buf[260] == 'a') && (buf[261] == 'r'))
{
/*vanilla tarball */
/*sprintf(s,"tar -xf - -C %s < %s",Theme_Path,Theme_Tar_Ball); */
g_snprintf(s, sizeof(s),
"(cd %s && tar -xf %s",
th, file);
} else
s[0] = '\0';
if (*s)
{
gint status = system(s);
if (status < 0)
return g_strdup(g_strerror (errno));
else if (status != 0)
return g_strdup_printf(_("Command '%s' failed"), s);
else
return NULL;
}
else
return g_strdup(_("Unknown file format"));
}
return FALSE;
}

View File

@@ -1,77 +0,0 @@
#include "da.h"
#include <errno.h>
gchar *
install_theme(gchar *file)
{
gchar s[4096];
gchar th[4096];
FILE *f;
guchar buf[1024];
gchar *theme_dir;
gchar *home;
if (isdir(file))
return FALSE;
theme_dir = gtk_rc_get_theme_dir();
if (geteuid() == 0)
g_snprintf(th, sizeof(th), "%s/", theme_dir);
else
{
home = g_get_home_dir();
if (!home)
{
g_free(theme_dir);
return g_strdup(_("Home directory doesn't exist!\n"));
}
g_snprintf(th, sizeof(th), "%s/.themes/", home);
}
g_free(theme_dir);
if (!isdir(th))
md(th);
if (!isfile(file))
return g_strdup(_("Theme does not exist"));
f = fopen(file, "r");
if (f)
{
fread(buf, 1, 1000, f);
fclose(f);
if ((buf[0] == 31) && (buf[1] == 139))
{
/*gzipped tarball */
/*sprintf(s,"gzip -d -c < %s | tar -xf - -C %s",Theme_Tar_Ball,Theme_Path); */
g_snprintf(s, sizeof(s),
"gzip -d -c < %s | (cd %s ; tar -xf -)",
file, th);
}
else if ((buf[257] == 'u') && (buf[258] == 's') && (buf[259] == 't') &&
(buf[260] == 'a') && (buf[261] == 'r'))
{
/*vanilla tarball */
/*sprintf(s,"tar -xf - -C %s < %s",Theme_Path,Theme_Tar_Ball); */
g_snprintf(s, sizeof(s),
"(cd %s && tar -xf %s",
th, file);
} else
s[0] = '\0';
if (*s)
{
gint status = system(s);
if (status < 0)
return g_strdup(g_strerror (errno));
else if (status != 0)
return g_strdup_printf(_("Command '%s' failed"), s);
else
return NULL;
}
else
return g_strdup(_("Unknown file format"));
}
return FALSE;
}

View File

@@ -1,217 +0,0 @@
#include "da.h"
#include <sys/types.h>
#include <utime.h>
#define MARK_STRING "# -- THEME AUTO-WRITTEN DO NOT EDIT\n"
static void
print_standard_stuff(FILE *fout, gchar *theme, gchar *font)
{
gchar *homedir;
homedir = g_strconcat ("include \"",
gnome_util_user_home(),
"/.gtkrc.mine\"\n\n", NULL);
fprintf(fout, MARK_STRING);
fprintf(fout, "include \"%s\"\n\n", theme);
if (font)
fprintf(fout, "style \"user-font\"\n{\n font=\"%s\"\n}\nwidget_class \"*\" style \"user-font\"\n\n", font);
fprintf(fout, homedir);
g_free (homedir);
fprintf(fout, MARK_STRING);
}
void
edit_file_to_use(gchar *file, gchar *theme, gchar *font)
{
FILE *fin, *fout;
gchar tmp[4096], buf[4096];
gchar nextline = 0, hastheme = 0;
srand(time(NULL));
g_snprintf(tmp, sizeof(tmp), "/tmp/gtkrc_%i", rand());
fout = fopen(tmp, "w");
if (!fout)
return;
fin = fopen(file, "r");
if (!fin)
{
print_standard_stuff (fout, theme, font);
fclose(fout);
cp(tmp, file);
return;
}
while (fgets(buf, sizeof(buf), fin))
{
if (!strcmp(MARK_STRING, buf))
hastheme += 1;
}
rewind(fin);
if (!hastheme)
{
print_standard_stuff (fout, theme, font);
while (fgets(buf, sizeof(buf), fin))
fprintf(fout, "%s", buf);
}
else if (hastheme == 1)
/* we keep this in for backwards compatability. */
{
nextline = 0;
while (fgets(buf, sizeof(buf), fin))
{
if (nextline == 1)
nextline = 0;
else if (!strcmp(MARK_STRING, buf))
{
print_standard_stuff (fout, theme, font);
nextline = 1;
}
else if (nextline == 0)
fprintf(fout, "%s", buf);
}
}
else
{
nextline = 0;
while (fgets(buf, sizeof(buf), fin))
{
if (!strcmp(MARK_STRING, buf))
{
if (nextline == 0)
{
nextline = 1;
print_standard_stuff (fout, theme, font);
}
else
{
nextline = 0;
}
} else if (nextline == 0)
fprintf(fout, "%s", buf);
}
}
fclose(fin);
fclose(fout);
cp(tmp, file);
rm(tmp);
}
void
set_tmp_rc(void)
{
gchar s[4096], *home;
home = g_get_home_dir ();
if (!home)
return;
g_snprintf(s, sizeof(s), "%s/.gtkrc", home);
srand(time(NULL));
g_snprintf(gtkrc_tmp, sizeof(gtkrc_tmp), "/tmp/%i-gtkrc-%i", time(NULL), rand());
cp(s, gtkrc_tmp);
}
void
use_theme(gchar *theme, gchar *font)
{
gchar s[4096], *home;
home = g_get_home_dir ();
if (!home)
return;
g_snprintf(s, sizeof(s), "%s/.gtkrc", home);
edit_file_to_use(s, theme, font);
}
void
test_theme(gchar *theme, gchar *font)
{
static time_t last_written_time = 0;
time_t current_time = time (NULL);
struct utimbuf buf;
edit_file_to_use(gtkrc_tmp, theme, font);
if (last_written_time >= current_time)
{
current_time = last_written_time + 1;
buf.actime = current_time;
buf.modtime = current_time;
utime (gtkrc_tmp, &buf);
}
last_written_time = current_time;
}
void
free_theme_list(ThemeEntry *list, gint number)
{
gint i;
for(i = 0; i < number; i++)
{
g_free(list[i].name);
g_free(list[i].rc);
g_free(list[i].readme);
g_free(list[i].icon);
}
g_free(list);
}
ThemeEntry *
list_themes(gchar *dir, gint *number)
{
gchar **dir_listing = NULL, tmp[4096];
ThemeEntry *list = NULL;
gint i = 0, j = 0, num = 0;
dir_listing = ls(dir, &num);
for(i = 0; i < num; i++)
{
g_snprintf(tmp, sizeof(tmp), "%s/%s/gtk/gtkrc", dir, dir_listing[i]);
if (isfile(tmp))
{
list = g_realloc(list, sizeof(ThemeEntry) * ++j);
list[j - 1].name = g_strdup(dir_listing[i]);
list[j - 1].rc = g_strdup(tmp);
g_snprintf(tmp, sizeof(tmp), "%s/%s", dir, dir_listing[i]);
list[j - 1].dir = g_strdup(tmp);
g_snprintf(tmp, sizeof(tmp), "%s/%s/README.html", dir, dir_listing[i]);
list[j - 1].readme = g_strdup(tmp);
g_snprintf(tmp, sizeof(tmp), "%s/%s/ICON.png", dir, dir_listing[i]);
list[j - 1].icon = g_strdup(tmp);
}
}
freestrlist(dir_listing, num);
*number = j;
return list;
}
ThemeEntry *
list_system_themes(gint *number)
{
gchar *theme_dir = NULL;
ThemeEntry *list = NULL;
theme_dir = gtk_rc_get_theme_dir();
list = list_themes(theme_dir, number);
g_free(theme_dir);
return list;
}
ThemeEntry *
list_user_themes(gint *number)
{
gchar *home = NULL;
gchar *theme_dir = NULL;
ThemeEntry *list = NULL;
home = g_get_home_dir ();
if (!home)
return NULL;
if (!isdir(home))
return NULL;
theme_dir = g_malloc(strlen(home) + strlen("/.themes") + 1);
sprintf(theme_dir, "%s%s", home, "/.themes");
list = list_themes(theme_dir, number);
g_free(theme_dir);
return list;
}

View File

@@ -1,217 +0,0 @@
#include "da.h"
#include <sys/types.h>
#include <utime.h>
#define MARK_STRING "# -- THEME AUTO-WRITTEN DO NOT EDIT\n"
static void
print_standard_stuff(FILE *fout, gchar *theme, gchar *font)
{
gchar *homedir;
homedir = g_strconcat ("include \"",
gnome_util_user_home(),
"/.gtkrc.mine\"\n\n", NULL);
fprintf(fout, MARK_STRING);
fprintf(fout, "include \"%s\"\n\n", theme);
if (font)
fprintf(fout, "style \"user-font\"\n{\n font=\"%s\"\n}\nwidget_class \"*\" style \"user-font\"\n\n", font);
fprintf(fout, homedir);
g_free (homedir);
fprintf(fout, MARK_STRING);
}
void
edit_file_to_use(gchar *file, gchar *theme, gchar *font)
{
FILE *fin, *fout;
gchar tmp[4096], buf[4096];
gchar nextline = 0, hastheme = 0;
srand(time(NULL));
g_snprintf(tmp, sizeof(tmp), "/tmp/gtkrc_%i", rand());
fout = fopen(tmp, "w");
if (!fout)
return;
fin = fopen(file, "r");
if (!fin)
{
print_standard_stuff (fout, theme, font);
fclose(fout);
cp(tmp, file);
return;
}
while (fgets(buf, sizeof(buf), fin))
{
if (!strcmp(MARK_STRING, buf))
hastheme += 1;
}
rewind(fin);
if (!hastheme)
{
print_standard_stuff (fout, theme, font);
while (fgets(buf, sizeof(buf), fin))
fprintf(fout, "%s", buf);
}
else if (hastheme == 1)
/* we keep this in for backwards compatability. */
{
nextline = 0;
while (fgets(buf, sizeof(buf), fin))
{
if (nextline == 1)
nextline = 0;
else if (!strcmp(MARK_STRING, buf))
{
print_standard_stuff (fout, theme, font);
nextline = 1;
}
else if (nextline == 0)
fprintf(fout, "%s", buf);
}
}
else
{
nextline = 0;
while (fgets(buf, sizeof(buf), fin))
{
if (!strcmp(MARK_STRING, buf))
{
if (nextline == 0)
{
nextline = 1;
print_standard_stuff (fout, theme, font);
}
else
{
nextline = 0;
}
} else if (nextline == 0)
fprintf(fout, "%s", buf);
}
}
fclose(fin);
fclose(fout);
cp(tmp, file);
rm(tmp);
}
void
set_tmp_rc(void)
{
gchar s[4096], *home;
home = g_get_home_dir ();
if (!home)
return;
g_snprintf(s, sizeof(s), "%s/.gtkrc", home);
srand(time(NULL));
g_snprintf(gtkrc_tmp, sizeof(gtkrc_tmp), "/tmp/%i-gtkrc-%i", time(NULL), rand());
cp(s, gtkrc_tmp);
}
void
use_theme(gchar *theme, gchar *font)
{
gchar s[4096], *home;
home = g_get_home_dir ();
if (!home)
return;
g_snprintf(s, sizeof(s), "%s/.gtkrc", home);
edit_file_to_use(s, theme, font);
}
void
test_theme(gchar *theme, gchar *font)
{
static time_t last_written_time = 0;
time_t current_time = time (NULL);
struct utimbuf buf;
edit_file_to_use(gtkrc_tmp, theme, font);
if (last_written_time >= current_time)
{
current_time = last_written_time + 1;
buf.actime = current_time;
buf.modtime = current_time;
utime (gtkrc_tmp, &buf);
}
last_written_time = current_time;
}
void
free_theme_list(ThemeEntry *list, gint number)
{
gint i;
for(i = 0; i < number; i++)
{
g_free(list[i].name);
g_free(list[i].rc);
g_free(list[i].readme);
g_free(list[i].icon);
}
g_free(list);
}
ThemeEntry *
list_themes(gchar *dir, gint *number)
{
gchar **dir_listing = NULL, tmp[4096];
ThemeEntry *list = NULL;
gint i = 0, j = 0, num = 0;
dir_listing = ls(dir, &num);
for(i = 0; i < num; i++)
{
g_snprintf(tmp, sizeof(tmp), "%s/%s/gtk/gtkrc", dir, dir_listing[i]);
if (isfile(tmp))
{
list = g_realloc(list, sizeof(ThemeEntry) * ++j);
list[j - 1].name = g_strdup(dir_listing[i]);
list[j - 1].rc = g_strdup(tmp);
g_snprintf(tmp, sizeof(tmp), "%s/%s", dir, dir_listing[i]);
list[j - 1].dir = g_strdup(tmp);
g_snprintf(tmp, sizeof(tmp), "%s/%s/README.html", dir, dir_listing[i]);
list[j - 1].readme = g_strdup(tmp);
g_snprintf(tmp, sizeof(tmp), "%s/%s/ICON.png", dir, dir_listing[i]);
list[j - 1].icon = g_strdup(tmp);
}
}
freestrlist(dir_listing, num);
*number = j;
return list;
}
ThemeEntry *
list_system_themes(gint *number)
{
gchar *theme_dir = NULL;
ThemeEntry *list = NULL;
theme_dir = gtk_rc_get_theme_dir();
list = list_themes(theme_dir, number);
g_free(theme_dir);
return list;
}
ThemeEntry *
list_user_themes(gint *number)
{
gchar *home = NULL;
gchar *theme_dir = NULL;
ThemeEntry *list = NULL;
home = g_get_home_dir ();
if (!home)
return NULL;
if (!isdir(home))
return NULL;
theme_dir = g_malloc(strlen(home) + strlen("/.themes") + 1);
sprintf(theme_dir, "%s%s", home, "/.themes");
list = list_themes(theme_dir, number);
g_free(theme_dir);
return list;
}

View File

@@ -1,37 +0,0 @@
#include <config.h>
#include "capplet-widget.h"
#include "da.h"
#define THEME_SWITCHER_VERSION "0.1"
int
main(int argc, char **argv)
{
GtkWidget *w;
gint child_pid;
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
set_tmp_rc();
child_pid = do_demo(argc, argv);
switch (gnome_capplet_init ("theme-switcher-capplet",
THEME_SWITCHER_VERSION, argc, argv, NULL, 0, NULL)) {
case -1:
exit (1);
case 1:
return 0;
}
w = make_main();
gtk_widget_show_all(w);
send_socket();
gtk_main();
/* Pause here until our child exits and the socket can be safely
* destroyed
*/
if (child_pid > 0)
waitpid(child_pid, NULL, 0);
return 0;
}

View File

@@ -1,14 +0,0 @@
#include "da.h"
void
signal_apply_theme(GtkWidget *widget)
{
GdkEventClient rcevent;
rcevent.type = GDK_CLIENT_EVENT;
rcevent.window = widget->window;
rcevent.send_event = TRUE;
rcevent.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
rcevent.data_format = 8;
gdk_event_send_clientmessage_toall((GdkEvent *)&rcevent);
}

View File

@@ -1,14 +0,0 @@
#include "da.h"
void
signal_apply_theme(GtkWidget *widget)
{
GdkEventClient rcevent;
rcevent.type = GDK_CLIENT_EVENT;
rcevent.window = widget->window;
rcevent.send_event = TRUE;
rcevent.message_type = gdk_atom_intern("_GTK_READ_RCFILES", FALSE);
rcevent.data_format = 8;
gdk_event_send_clientmessage_toall((GdkEvent *)&rcevent);
}

View File

@@ -1,55 +0,0 @@
[Desktop Entry]
Name=Theme Selector
Name[ca]=Selector de temes
Name[cs]=Výbìr tématu
Name[da]=Temavælger
Name[de]=Thema auswählen
Name[es]=Selector de Temas
Name[et]=Teemad
Name[fi]=Teemavalitsin
Name[fr]=Selecteur de Thèmes
Name[gl]=Escoller temas
Name[hu]=Témaválasztó
Name[it]=Selettore temi
Name[ja]=¥Æ¡¼¥Þ¥»¥ì¥¯¥¿
Name[ko]=Å׸¶ ¼±ÅÃ
Name[lt]=Temos parinkimas
Name[no]=Temavelger
Name[pl]=Wybór motywu
Name[pt]=Selector de Temas
Name[ru]=ðÅÒÅËÌÀÞÁÔÅÌØ ÔÅÍ
Name[sl]=Izbirnik Tem
Name[sv]=Temaväljare
Name[uk]=÷ÉÂ¦Ò ÔÅÍ
Name[wa]=Tinmes do scribanne
Name[zh_TW.Big5]=§G´º¥DÃD
Name[zh_CN.GB2312]=²¼¾°Ö÷Ìâ
Comment=Select which desktop theme to use.
Comment[ca]=Seleccionar un tema per l'escriptori.
Comment[cs]=Zmìna aktuálního tématu - barev, stylu tlaèítek atd.
Comment[da]=Vælg hvilket skrivebordstema du vil bruge.
Comment[de]=Desktop-Thema auswählen
Comment[es]=Seleccionar el tema deseado para el escritorio
Comment[et]=Töölaua teemade valik
Comment[fi]=Valitsee käytettävän työpöytäteeman.
Comment[fr]=Choisir un thème pour le bureau
Comment[gl]=Escoller qué tema usar para o escritorio
Comment[hu]=A GNOME alkalmazások kinézetét meghatározó téma
Comment[it]=Selezione del tema da usare per il desktop
Comment[ja]=¥Ç¥¹¥¯¥È¥Ã¥×¥Æ¡¼¥Þ¤ÎÁªÂò
Comment[ko]=¾î¶² µ¥½ºÅ©Å¾ Å׸¶¸¦ »ç¿ëÇÒ Áö ¼±ÅÃ
Comment[lt]=Pasirink, kurià darbo aplinkos temà naudoti
Comment[no]=Velger tema for skrivebordet
Comment[pl]=Wybór motywu zdobieñ biurka
Comment[pt]=Selecciona qual o tema a utilizar.
Comment[ru]=÷ÙÂÏÒ ÔÅÍÙ
Comment[sl]=Nastavite katera namizna tema naj se uporablja.
Comment[sv]=Välj tema för skrivbordet.
Comment[uk]=÷ÉÂ¦Ò ÔÅÍÉ ÒÏÂÏÞÏÇÏ ÓÔÏÌÁ
Comment[wa]=Tchwezixhoz les tinmes ki vos voloz po li scribanne
Comment[zh_TW.Big5]=¿ï¾Ü±z­n¨Ï¥Îªº§G´º¥DÃD
Comment[zh_CN.GB2312]=Ñ¡ÔñÄúҪʹÓõIJ¼¾°Ö÷Ìâ
Exec=theme-selector-capplet
Icon=gnome-ccthemes.png
Terminal=0
Type=Application

View File

@@ -1,33 +0,0 @@
1999-06-11 Ettore Perazzoli <ettore@comm2000.it>
* url-properties.c (main): Exit with an error if
`gnome_capplet_init()' returns an error. Bug reported by Nicola
Pero <n.pero@mi.flashnet.it>.
1999-05-16 Jacob Berkman <jberk+@cmu.edu>
* url-properties.c (url_capplet_commit): added a
gnome_config_sync() so the changes actually get saved.
(gnome bug #169)
1998-12-12 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* url-properties.c: Change included "config.h" to <config.h>.
* url-properties.desktop: Added Portuguese translation.
1998-12-11 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* .cvsignore: Added this file.
1998-12-08 James Henstridge <james@daa.com.au>
* url-properties.c: forgot the copyright message at the top of the
file.
1998-12-08 James Henstridge <james@daa.com.au>
* url-properties.c, url-properties.desktop, Makefile.am: A new capplet
that can be used to configure the behaviour of the gnome_url_show
function.

View File

@@ -1,24 +0,0 @@
INCLUDES = -I. -I$(srcdir) \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(srcdir)/../../control-center \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) $(GNOME_INCLUDEDIR) \
-DGNOMESYSCONFDIR=\""$(sysconfdir)"\"
bin_PROGRAMS = url-properties
url_properties_SOURCES = url-properties.c
url_properties_LDADD = ../../control-center/libcapplet.la \
$(GNOME_LIBS) $(ORBIT_LIBS) \
$(GNOMEUI_LIBS) $(INTLLIBS)
EXTRA_DIST = \
url-properties.desktop
sysdir = $(datadir)/control-center
sys_DATA = url-properties.desktop
install-data-local:
$(INSTALL_DATA) $(srcdir)/url-properties.desktop $(DESTDIR)$(datadir)/gnome/apps/Settings/url-properties.desktop

View File

@@ -1,290 +0,0 @@
/* url-properties -- a capplet to configure the behaviour of gnome_url_show
* Copyright (C) 1998 James Henstridge <james@daa.com.au>
*
* 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 of the License, 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
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <gtk/gtk.h>
#include "capplet-widget.h"
#include <gnome.h>
GtkWidget *capplet, *protocol, *combo, *clist;
void url_capplet_revert(void);
void url_capplet_commit(void);
void url_capplet_cancel(void);
void build_capplet(void);
int
main(int argc, char *argv[]) {
gint init_ret;
bindtextdomain(PACKAGE, GNOMELOCALEDIR);
textdomain(PACKAGE);
init_ret = gnome_capplet_init("url-properties", VERSION, argc, argv,
NULL, 0, NULL);
if (init_ret == 1) {
/* nothing to init */
return 0;
} else if (init_ret == -1) {
g_error (_("Error initializing the `url-properties' capplet."));
}
build_capplet();
url_capplet_revert(); /* this will refill the clist */
gtk_signal_connect(GTK_OBJECT(capplet), "revert",
GTK_SIGNAL_FUNC(url_capplet_revert), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "ok",
GTK_SIGNAL_FUNC(url_capplet_commit), NULL);
gtk_signal_connect(GTK_OBJECT(capplet), "cancel",
GTK_SIGNAL_FUNC(url_capplet_cancel), NULL);
capplet_gtk_main();
return 0;
}
void set_handler(GtkEntry *entry);
void remove_handler(GtkButton *button);
void select_clist_row(GtkCList *clist, gint row, gint column);
void build_capplet(void) {
GtkWidget *vbox, *hbox, *item, *button;
gchar *titles[] = { N_("Protocol"), N_("Command") };
capplet = capplet_widget_new();
vbox = gtk_vbox_new(FALSE, 5);
gtk_container_add(GTK_CONTAINER(capplet), vbox);
gtk_widget_show(vbox);
hbox = gtk_hbox_new(FALSE, 5);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
gtk_widget_show(hbox);
protocol = gtk_entry_new();
gtk_widget_set_usize(protocol, 80, -1);
gtk_box_pack_start(GTK_BOX(hbox), protocol, FALSE, TRUE, 0);
gtk_widget_show(protocol);
item = gtk_label_new(_("handler:"));
gtk_box_pack_start(GTK_BOX(hbox), item, FALSE, TRUE, 0);
gtk_widget_show(item);
combo = gtk_combo_new();
gtk_combo_set_use_arrows(GTK_COMBO(combo), FALSE);
gtk_combo_set_value_in_list(GTK_COMBO(combo), FALSE, FALSE);
gtk_combo_disable_activate(GTK_COMBO(combo));
/* set some commonly used handlers */
item = gtk_list_item_new_with_label(_("Netscape"));
gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item),
"gnome-moz-remote '%s'");
gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item);
gtk_widget_show(item);
item = gtk_list_item_new_with_label(_("Netscape (new window)"));
gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item),
"gnome-moz-remote --newwin '%s'");
gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item);
gtk_widget_show(item);
item = gtk_list_item_new_with_label(_("Help browser"));
gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item),
"gnome-help-browser '#%s'");
gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item);
gtk_widget_show(item);
item = gtk_list_item_new_with_label(_("Help browser (new window)"));
gtk_combo_set_item_string(GTK_COMBO(combo), GTK_ITEM(item),
"gnome-help-browser '%s'");
gtk_container_add(GTK_CONTAINER(GTK_COMBO(combo)->list), item);
gtk_widget_show(item);
gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);
gtk_widget_show(combo);
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "activate",
GTK_SIGNAL_FUNC(set_handler), NULL);
button = gtk_button_new_with_label(_("Set"));
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
gtk_widget_show(button);
gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(set_handler),
GTK_OBJECT(GTK_COMBO(combo)->entry));
button = gtk_button_new_with_label(_("Remove"));
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, TRUE, 0);
gtk_widget_show(button);
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(remove_handler), NULL);
item = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(item),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(vbox), item, TRUE, TRUE, 0);
gtk_widget_show(item);
titles[0] = _(titles[0]);
titles[1] = _(titles[1]);
clist = gtk_clist_new_with_titles(2, titles);
gtk_container_add(GTK_CONTAINER(item), clist);
gtk_widget_show(clist);
gtk_clist_set_column_width(GTK_CLIST(clist), 0, 50);
gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_BROWSE);
gtk_clist_set_sort_type(GTK_CLIST(clist), GTK_SORT_ASCENDING);
gtk_clist_set_sort_column(GTK_CLIST(clist), 0);
gtk_clist_set_auto_sort(GTK_CLIST(clist), TRUE);
gtk_signal_connect(GTK_OBJECT(clist), "select_row",
GTK_SIGNAL_FUNC(select_clist_row), NULL);
gtk_widget_show(capplet);
}
void url_capplet_revert(void) {
void *iter;
gchar *key, *value;
gint len;
gboolean def = FALSE;
/* see if the default is set. If not, put in some sensible defaults.
* Maybe this should pass a call through to gnome-url */
g_free(gnome_config_get_string_with_default(
"/Gnome/URL Handlers/default-show=?", &def));
if (def) {
gnome_config_set_string("/Gnome/URL Handlers/default-show",
"gnome-moz-remote --newwin \"%s\"");
g_free(gnome_config_get_string_with_default(
"/Gnome/URL Handlers/info-show=?", &def));
if (def)
gnome_config_set_string("/Gnome/URL Handlers/info-show",
"gnome-help-browser \"%s\"");
g_free(gnome_config_get_string_with_default(
"/Gnome/URL Handlers/man-show=?", &def));
if (def)
gnome_config_set_string("/Gnome/URL Handlers/man-show",
"gnome-help-browser \"%s\"");
g_free(gnome_config_get_string_with_default(
"/Gnome/URL Handlers/ghelp-show=?", &def));
if (def)
gnome_config_set_string("/Gnome/URL Handlers/ghelp-show",
"gnome-help-browser \"%s\"");
}
iter = gnome_config_init_iterator("/Gnome/URL Handlers");
gtk_clist_freeze(GTK_CLIST(clist));
gtk_clist_clear(GTK_CLIST(clist));
while ((iter = gnome_config_iterator_next(iter, &key, &value))) {
len = strlen(key);
if (len > 5 && !strcmp(&key[len-5], "-show")) {
gchar *row[2];
gint id;
/* it is a *-show key */
key[len-5] = '\0';
row[0] = key;
row[1] = value;
id = gtk_clist_append(GTK_CLIST(clist), row);
if (!g_strcasecmp(key, "default"))
gtk_clist_select_row(GTK_CLIST(clist), id, 0);
}
g_free(key);
g_free(value);
}
gtk_clist_thaw(GTK_CLIST(clist));
}
void url_capplet_commit(void) {
gint num_rows, row;
gchar *col1, *col2, *key;
/* should we be more specific here?*/
gnome_config_clean_section("/Gnome/URL Handlers");
num_rows = GTK_CLIST(clist)->rows;
for (row = 0; row < num_rows; row++) {
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1);
gtk_clist_get_text(GTK_CLIST(clist), row, 1, &col2);
key = g_strconcat("/Gnome/URL Handlers/", col1, "-show", NULL);
gnome_config_set_string(key, col2);
g_free(key);
}
gnome_config_sync();
gtk_main_quit();
}
void url_capplet_cancel(void) {
gtk_main_quit();
}
void set_handler(GtkEntry *entry) {
gint row, num_rows;
gchar *col1, *prot, *cols[2];
num_rows = GTK_CLIST(clist)->rows;
prot = gtk_entry_get_text(GTK_ENTRY(protocol));
for (row = 0; row < num_rows; row++) {
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1);
if (!g_strcasecmp(prot, col1)) {
gtk_clist_set_text(GTK_CLIST(clist), row, 1, gtk_entry_get_text(entry));
capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
return;
}
}
/* prot not in clist */
cols[0] = prot;
cols[1] = gtk_entry_get_text(entry);
gtk_clist_append(GTK_CLIST(clist), cols);
capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
}
void remove_handler(GtkButton *button) {
gint row, num_rows;
gchar *col1, *prot;
num_rows = GTK_CLIST(clist)->rows;
prot = gtk_entry_get_text(GTK_ENTRY(protocol));
for (row = 0; row < num_rows; row++) {
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1);
if (!g_strcasecmp(prot, col1)) {
gtk_clist_remove(GTK_CLIST(clist), row);
capplet_widget_state_changed(CAPPLET_WIDGET(capplet), TRUE);
gtk_entry_set_text(GTK_ENTRY(protocol), "");
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), "");
if (num_rows > 1)
gtk_clist_select_row(GTK_CLIST(clist), 0, 0);
return;
}
}
}
void select_clist_row(GtkCList *clist, gint row, gint column) {
gchar *col1, *col2;
/* get column values */
gtk_clist_get_text(GTK_CLIST(clist), row, 0, &col1);
gtk_clist_get_text(GTK_CLIST(clist), row, 1, &col2);
gtk_entry_set_text(GTK_ENTRY(protocol), col1);
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry), col2);
}

View File

@@ -1,29 +0,0 @@
INCLUDES = -I. -I$(srcdir) \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(srcdir)/../../control-center \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(includedir) $(GNOME_INCLUDEDIR) $(IMLIB_CFLAGS)
bin_PROGRAMS = wm-properties-capplet
wm_properties_capplet_SOURCES = \
wm-properties.h \
wm-properties-capplet.c \
wm-list.c \
wm-exec.c
wm_properties_capplet_LDADD = \
../../control-center/libcapplet.la \
$(GNOME_LIBS) $(ORBIT_LIBS) $(GNOMEUI_LIBS) $(INTLLIBS) \
$(IMLIB_LIBS)
EXTRA_DIST = wm-properties.desktop
SUBDIRS=wm-desktops
sysdir = $(datadir)/control-center/Desktop
sys_DATA = wm-properties.desktop
Setdir = $(datadir)/gnome/apps/Settings/Desktop
Set_DATA = wm-properties.desktop

View File

@@ -1,11 +0,0 @@
wmdatadir = $(datadir)/gnome/wm-properties
wmdata_DATA=\
Enlightenment.desktop \
IceWM.desktop \
Scwm.desktop \
WindowMaker.desktop \
twm.desktop
EXTRA_DIST= $(wmdata_DATA)

View File

@@ -1,332 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Code available under the Gnu GPL.
* Authors: Owen Taylor <otaylor@redhat.com>
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <libgnome/libgnome.h>
#include "wm-properties.h"
typedef struct _RestartInfo RestartInfo;
struct _RestartInfo {
GnomeDesktopEntry *dentry;
gint retries;
WMResultFunc callback;
gpointer data;
};
gboolean
wm_is_running (void)
{
gboolean result;
gboolean old_warnings = gdk_error_warnings;
guint old_mask;
XWindowAttributes attrs;
gdk_error_warnings = FALSE;
gdk_error_code = 0;
XGetWindowAttributes (GDK_DISPLAY(), GDK_ROOT_WINDOW(), &attrs);
XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
SubstructureRedirectMask);
XSync (GDK_DISPLAY(), False);
if (gdk_error_code == 0) {
result = FALSE;
XSelectInput (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
attrs.your_event_mask);
} else
result = TRUE;
gdk_error_warnings = old_warnings;
return result;
}
/* Cut and paste from gnome-libs/gnome_win_hints_wm_exists, except that we
* return the xid instead of a window
*/
static Window
find_gnome_wm_window(void)
{
Atom r_type;
int r_format;
unsigned long count;
unsigned long bytes_remain;
unsigned char *prop, *prop2;
gint prev_error;
GdkAtom cardinal_atom = gdk_atom_intern ("CARDINAL", FALSE);
prev_error = gdk_error_warnings;
gdk_error_warnings = 0;
if (XGetWindowProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
gdk_atom_intern ("_WIN_SUPPORTING_WM_CHECK", FALSE),
0, 1, False, cardinal_atom,
&r_type, &r_format,
&count, &bytes_remain, &prop) == Success && prop)
{
if (r_type == cardinal_atom && r_format == 32 && count == 1)
{
Window n = *(long *)prop;
if (XGetWindowProperty(GDK_DISPLAY(), n,
gdk_atom_intern ("_WIN_SUPPORTING_WM_CHECK", FALSE),
0, 1, False, cardinal_atom,
&r_type, &r_format, &count, &bytes_remain,
&prop2) == Success && prop)
{
if (r_type == cardinal_atom && r_format == 32 && count == 1)
{
XFree(prop);
XFree(prop2);
gdk_error_warnings = prev_error;
return n;
}
XFree(prop2);
}
}
XFree(prop);
}
gdk_error_warnings = prev_error;
return None;
}
static Window
find_wm_window_from_client (GdkWindow *client)
{
Window window, frame, parent, root;
Window *children;
unsigned int nchildren;
gboolean old_warnings;
if (!client)
return None;
frame = None;
window = GDK_WINDOW_XWINDOW (client);
old_warnings = gdk_error_warnings;
gdk_error_warnings = FALSE;
gdk_error_code = 0;
while (XQueryTree (GDK_DISPLAY(), window,
&root, &parent, &children, &nchildren) &&
(gdk_error_code == 0)) {
if (children)
XFree(children);
if (window == root)
break;
if (root == parent) {
frame = window;
break;
}
window = parent;
}
gdk_error_warnings = old_warnings;
return frame;
}
static gboolean
window_has_wm_state (Window window)
{
Atom r_type;
int r_format;
unsigned long count;
unsigned long bytes_remain;
unsigned char *prop;
if (XGetWindowProperty(GDK_DISPLAY(), window,
gdk_atom_intern ("WM_STATE", FALSE),
0, 0, False, AnyPropertyType,
&r_type, &r_format,
&count, &bytes_remain, &prop) == Success) {
if (r_type != None) {
XFree(prop);
return TRUE;
}
}
return FALSE;
}
static gboolean
descendent_has_wm_state (Window window)
{
gboolean result = FALSE;
Window parent, root;
Window *children;
unsigned int nchildren;
gint i;
if (!XQueryTree (GDK_DISPLAY(), window,
&root, &parent, &children, &nchildren))
return FALSE;
for (i=0; i<nchildren; i++) {
if (window_has_wm_state (children[i]) ||
descendent_has_wm_state (children[i])) {
result = TRUE;
break;
}
}
if (children)
XFree (children);
return result;
}
/* This function tries to find a window manager frame by
* hunting all the children of the root window
*/
static Window
find_wm_window_from_hunt (void)
{
Window parent, root, frame;
Window *children;
unsigned int nchildren;
gboolean old_warnings;
gint i;
frame = None;
old_warnings = gdk_error_warnings;
gdk_error_warnings = FALSE;
gdk_error_code = 0;
XQueryTree (GDK_DISPLAY(), gdk_root_window,
&root, &parent, &children, &nchildren);
/* We are looking for a window that doesn't have WIN_STATE
* set on it, but does have a child with WIN_STATE set
*/
for (i=0; i<nchildren; i++) {
if (!window_has_wm_state (children[i]) &&
descendent_has_wm_state (children[i])) {
frame = children[i];
break;
}
}
if (children)
XFree (children);
gdk_error_warnings = old_warnings;
return frame;
}
static Window
find_wm_window (GdkWindow *client)
{
Window wm_window = None;
/* First, try to find a GNOME compliant WM */
wm_window = find_gnome_wm_window();
if (!wm_window) {
wm_window = find_wm_window_from_client (client);
}
if (!wm_window) {
wm_window = find_wm_window_from_hunt ();
}
return wm_window;
}
static gboolean
start_timeout (gpointer data)
{
RestartInfo *info = data;
if (wm_is_running ()) {
info->callback(WM_SUCCESS, info->data);
gnome_desktop_entry_free (info->dentry);
g_free (info);
return FALSE;
} else {
info->retries--;
if (info->retries > 0)
return TRUE;
else {
info->callback(WM_CANT_START, info->data);
gnome_desktop_entry_free (info->dentry);
g_free (info);
return FALSE;
}
}
}
static void
start_do (RestartInfo *info)
{
gnome_desktop_entry_launch (info->dentry);
info->retries = 10;
gtk_timeout_add (1000, start_timeout, info);
}
static gboolean
kill_timeout (gpointer data)
{
RestartInfo *info = data;
if (!wm_is_running ()) {
start_do (info);
return FALSE;
} else {
info->retries--;
if (info->retries > 0)
return TRUE;
else {
info->callback(WM_ALREADY_RUNNING, info->data);
gnome_desktop_entry_free (info->dentry);
g_free (info);
return FALSE;
}
}
}
void
wm_restart (WindowManager *new,
GdkWindow *client,
WMResultFunc callback,
gpointer data)
{
Window wm_window;
RestartInfo *info;
g_return_if_fail (new->is_present);
info = g_new (RestartInfo, 1);
info->dentry = gnome_desktop_entry_copy (new->dentry);
info->callback = callback;
info->data = data;
info->retries = 10;
if (wm_is_running ()) {
wm_window = find_wm_window (client);
if (!wm_window) {
(*callback) (WM_ALREADY_RUNNING, data);
gnome_desktop_entry_free (info->dentry);
g_free (info);
} else {
XKillClient (GDK_DISPLAY(), wm_window);
gtk_timeout_add (1000, kill_timeout, info);
}
} else {
start_do (info);
}
}
WindowManager *
wm_guess_current (void)
{
return NULL;
}

View File

@@ -1,407 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Code available under the Gnu GPL.
* Authors: Owen Taylor <otaylor@redhat.com>
*/
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
#include <ctype.h>
#include <libgnome/libgnome.h>
#include "wm-properties.h"
/* Current list of window managers */
GList *window_managers = NULL;
/* List on startup */
static GList *window_managers_save = NULL;
/* Current window manager */
static WindowManager *current_wm = NULL;
/* Window manager on startup */
static WindowManager *current_wm_save = NULL;
gboolean
is_blank (gchar *str)
{
while (*str) {
if (!isspace(*str))
return FALSE;
str++;
}
return TRUE;
}
static gint
wm_compare (gconstpointer a, gconstpointer b)
{
const WindowManager *wm_a = (const WindowManager *)a;
const WindowManager *wm_b = (const WindowManager *)b;
return g_strcasecmp (wm_a->dentry->name, wm_b->dentry->name);
}
static void
wm_free (WindowManager *wm)
{
gnome_desktop_entry_free (wm->dentry);
g_free (wm->config_exec);
g_free (wm->config_tryexec);;
g_free (wm);
}
void
wm_check_present (WindowManager *wm)
{
gchar *path;
if (wm->dentry->exec) {
if (wm->dentry->tryexec) {
path = gnome_is_program_in_path (wm->dentry->tryexec);
wm->is_present = (path != NULL);
if (path)
g_free (path);
} else
wm->is_present = TRUE;
} else
wm->is_present = FALSE;
if (wm->config_exec) {
if (wm->config_tryexec) {
path = gnome_is_program_in_path (wm->config_tryexec);
wm->is_config_present = (path != NULL);
if (path)
g_free (path);
} else
wm->is_config_present = TRUE;
} else
wm->is_config_present = FALSE;
}
static WindowManager *
wm_copy (WindowManager *wm)
{
WindowManager *result = g_new (WindowManager, 1);
result->dentry = gnome_desktop_entry_copy (wm->dentry);
result->config_exec = g_strdup (wm->config_exec);
result->config_tryexec = g_strdup (wm->config_tryexec);
result->session_managed = wm->session_managed;
result->is_user = wm->is_user;
result->is_present = wm->is_present;
result->is_config_present = wm->is_config_present;
return result;
}
static WindowManager *
wm_list_find (GList *list, gchar *name)
{
GList *tmp_list = list;
while (tmp_list) {
WindowManager *wm = tmp_list->data;
if (strcmp (wm->dentry->name, name) == 0)
return wm;
tmp_list = tmp_list->next;
}
return NULL;
}
static WindowManager *
wm_list_find_exec (GList *list, gchar *name)
{
GList *tmp_list = list;
while (tmp_list) {
WindowManager *wm = tmp_list->data;
if (!wm->dentry->exec || !wm->dentry->exec[0])
continue;
if (strcmp (wm->dentry->exec[0], name) == 0)
return wm;
tmp_list = tmp_list->next;
}
return NULL;
}
static GList *
wm_list_find_files (gchar *directory)
{
DIR *dir;
struct dirent *child;
GList *result = NULL;
gchar *suffix;
dir = opendir (directory);
if (dir == NULL)
return NULL;
while ((child = readdir (dir)) != NULL) {
/* Ignore files without .desktop suffix, and ignore
* .desktop files with no prefix
*/
suffix = child->d_name + strlen (child->d_name) - 8;
/* strlen(".desktop") == 8 */
if (suffix <= child->d_name ||
strcmp (suffix, ".desktop") != 0)
continue;
result = g_list_prepend (result,
g_concat_dir_and_file (directory,
child->d_name));
}
closedir (dir);
return result;
}
static void
wm_list_read_dir (gchar *directory, gboolean is_user)
{
WindowManager *wm;
GList *tmp_list;
GList *files;
gchar *prefix;
files = wm_list_find_files (directory);
tmp_list = files;
while (tmp_list) {
wm = g_new (WindowManager, 1);
wm->dentry = gnome_desktop_entry_load_unconditional (tmp_list->data);
if (!wm->dentry) {
g_free (wm);
tmp_list = tmp_list->next;
continue;
}
prefix = g_strconcat ("=", wm->dentry->location, "=/Window Manager/", NULL);
gnome_config_push_prefix (prefix);
g_free (prefix);
wm->config_exec = gnome_config_get_string ("ConfigExec");
wm->config_tryexec = gnome_config_get_string ("ConfigTryExec");
wm->session_managed = gnome_config_get_bool ("SessionManaged=0");
wm->is_user = is_user;
if (wm->config_exec && is_blank (wm->config_exec)) {
g_free (wm->config_exec);
wm->config_exec = NULL;
}
gnome_config_pop_prefix ();
wm_check_present (wm);
if (wm->dentry->name && wm->dentry->exec &&
(wm->is_user || wm->is_present)) {
window_managers =
g_list_insert_sorted (window_managers,
wm,
wm_compare);
window_managers_save =
g_list_insert_sorted (window_managers_save,
wm_copy (wm),
wm_compare);
} else {
wm_free (wm);
}
tmp_list = tmp_list->next;
}
g_list_free (files);
}
void
wm_list_init (void)
{
gchar *tempdir;
gchar *name;
tempdir = gnome_unconditional_datadir_file ("gnome/wm-properties/");
wm_list_read_dir (tempdir, FALSE);
g_free (tempdir);
tempdir = gnome_util_home_file("wm-properties/");
wm_list_read_dir (tempdir, TRUE);
g_free (tempdir);
name = gnome_config_get_string ("wm-properties/Config/Config/Current");
if (name) {
current_wm = wm_list_find (window_managers, name);
g_free (name);
}
if (!current_wm) {
name = gnome_config_get_string ("default.wm/Default/WM");
if (name) {
current_wm = wm_list_find_exec (window_managers, name);
g_free (name);
}
}
if (!current_wm) {
gchar *wmfile, *prefix;
wmfile = gnome_unconditional_datadir_file ("default.wm");
prefix = g_strconcat ("=", wmfile, "=/Default/WM", NULL);
name = gnome_config_get_string (prefix);
g_free (wmfile);
g_free (prefix);
if (name) {
current_wm = wm_list_find_exec (window_managers, name);
g_free (name);
}
}
if (!current_wm && window_managers)
current_wm = window_managers->data;
if(current_wm)
current_wm_save = wm_list_find (window_managers_save, current_wm->dentry->name);
}
void
wm_list_save (void)
{
GList *old_files;
GList *tmp_list;
gchar *tempdir;
gchar *prefix;
WindowManager *wm;
/* Clean out the current contents of .gnome/wm-desktops
*/
tempdir = gnome_util_home_file("wm-properties/");
old_files = wm_list_find_files (tempdir);
g_free (tempdir);
tmp_list = old_files;
while (tmp_list) {
prefix = g_strconcat ("=", tmp_list->data, "=", NULL);
gnome_config_clean_file (prefix);
gnome_config_sync_file (prefix);
g_free (prefix);
tmp_list = tmp_list->next;
}
g_list_free (old_files);
/* Save the user's desktops
*/
tmp_list = window_managers;
while (tmp_list) {
wm = tmp_list->data;
if (wm->is_user) {
gnome_desktop_entry_save (wm->dentry);
prefix = g_strconcat ("=", wm->dentry->location, "=/Window Manager/", NULL);
gnome_config_push_prefix (prefix);
g_free (prefix);
if (wm->config_exec)
gnome_config_set_string ("ConfigExec", wm->config_exec);
if (wm->config_tryexec)
gnome_config_set_string ("ConfigTryExec", wm->config_tryexec);
gnome_config_set_bool ("SessionManaged=0", wm->session_managed);
gnome_config_pop_prefix ();
}
tmp_list = tmp_list->next;
}
/* Save the current window manager
*/
if(current_wm)
gnome_config_set_string ("wm-properties/Config/Config/Current",
current_wm->dentry->name);
gnome_config_sync ();
}
void
wm_list_revert (void)
{
GList *tmp_list;
gchar *old_name = NULL;
if(current_wm)
old_name = g_strdup (current_wm->dentry->name);
g_list_foreach (window_managers, (GFunc)wm_free, NULL);
g_list_free (window_managers);
window_managers = NULL;
tmp_list = window_managers_save;
while (tmp_list) {
window_managers = g_list_prepend (window_managers,
wm_copy (tmp_list->data));
tmp_list = tmp_list->next;
}
window_managers = g_list_reverse (window_managers);
current_wm = wm_list_find (window_managers, old_name);
g_free (old_name);
}
void
wm_list_add (WindowManager *wm)
{
g_return_if_fail (wm != NULL);
window_managers = g_list_insert_sorted (window_managers, wm,
wm_compare);
}
void
wm_list_delete (WindowManager *wm)
{
GList *node;
g_return_if_fail (wm != NULL);
g_return_if_fail (wm != current_wm);
node = g_list_find (window_managers, wm);
g_return_if_fail (node != NULL);
window_managers = g_list_remove_link (window_managers, node);
g_list_free_1 (node);
wm_free (wm);
}
void
wm_list_set_current (WindowManager *wm)
{
current_wm = wm;
}
WindowManager *
wm_list_get_current (void)
{
return current_wm;
}
WindowManager *
wm_list_get_revert (void)
{
if(current_wm_save)
return wm_list_find (window_managers, current_wm_save->dentry->name);
else
return NULL;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,56 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/* Copyright (C) 1998 Redhat Software Inc.
* Code available under the Gnu GPL.
* Authors: Owen Taylor <otaylor@redhat.com>
*/
#include <gdk/gdk.h>
#include <libgnome/libgnome.h>
typedef struct _WindowManager WindowManager;
struct _WindowManager {
GnomeDesktopEntry *dentry;
gchar *config_exec;
gchar *config_tryexec;
gboolean session_managed : 1;
gboolean is_user : 1;
gboolean is_present : 1;
gboolean is_config_present : 1;
};
/* Utility functions */
gboolean is_blank (gchar *str);
/* Fill in the is_present and is_config_present fields */
void wm_check_present (WindowManager *wm);
/* Management of window manager list */
void wm_list_init (void);
void wm_list_save (void);
void wm_list_revert (void);
void wm_list_add (WindowManager *window_manager);
void wm_list_delete (WindowManager *window_manager);
void wm_list_set_current (WindowManager *window_manager);
WindowManager *wm_list_get_current (void);
WindowManager *wm_list_get_revert (void);
extern GList *window_managers;
/* Management of current window manager */
typedef enum {
WM_SUCCESS,
WM_ALREADY_RUNNING,
WM_CANT_START
} WMResult;
typedef void (*WMResultFunc) (WMResult result, gpointer data);
void wm_restart (WindowManager *new,
GdkWindow *client,
WMResultFunc callback,
gpointer data);
gboolean wm_is_running (void);
WindowManager *wm_guess_current (void);

View File

@@ -1,98 +0,0 @@
AC_INIT(control-center)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(control-center, 1.0.51)
AM_MAINTAINER_MODE
dnl
dnl let applications configure for gnome
dnl
gnome_cv_use_gnome=yes
AM_PATH_GNOME
AC_ISC_POSIX
AC_PROG_CC
AC_STDC_HEADERS
AC_ARG_PROGRAM
AM_PROG_LIBTOOL
AM_PROG_LEX
AC_PROG_YACC
dnl utility conditional
AM_CONDITIONAL(FALSE, test "x" = "y")
ALL_LINGUAS="ca cs da de el en_GB es et fi fr ga gl hr hu it ja ko lt nl no pl pt pt_BR ro ru sl sv tr uk zh_CN.GB2312 zh_TW.Big5"
AM_GNOME_GETTEXT
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_CHECK_HEADERS(dlfcn.h dl.h)
AC_CHECK_LIB(dl, dlopen, DL_LIB="-ldl",[
AC_CHECK_LIB(dld, shl_load, DL_LIB="-ldld",[
AC_CHECK_FUNCS(dlopen, DL_LIB="",
AC_MSG_ERROR(Dynamic linking is not available on this platform. Some
apps, like panel, will not run properly.))
])])
AC_SUBST(DL_LIB)
AC_CHECK_FUNCS(usleep)
dnl keyboard-properties-capplet
AC_CHECK_HEADERS(X11/extensions/xf86misc.h, XF86MISC_LIBS="-lXxf86misc")
AC_SUBST(XF86MISC_LIBS)
AM_PATH_ORBIT(0.5.1, , AC_MSG_ERROR([You must have ORBit installed.]))
AM_PATH_OAF(0.1.0, , AC_MSG_ERROR([You must have OAF installed.]))
AM_PATH_GCONF(0.1.0, , AC_MSG_ERROR([You must have GConf installed.]), gconf-gtk)
AM_PATH_LIBGLADE(,AC_MSG_ERROR([You must have LibGlade installed.]), gnome)
dnl esd-manager
have_libesd=no
AM_PATH_ESD(,have_libesd=yes,
[AC_MSG_WARN([*** \`esd-manager' will not be built ***])])
AM_CONDITIONAL(HAVE_LIBESD, test yes = $have_libesd)
if test "$have_libesd" = yes; then
AC_DEFINE(HAVE_ESD)
AC_DEFINE(HAVE_LIBESD)
fi
dnl session-properties
AM_CONDITIONAL(SESSION, test "$GNOME_HAVE_SM" = true)
AM_PATH_IMLIB(1.8.2, , [
echo "ERROR: Needs a system with Imlib 1.8.2 or higher"
echo "You can obtain it from:"
echo "ftp://ftp.enlightenment.org/pub/enlightenment/"
echo "ftp://www.rasterman.com/pub/enlightenment/"
echo "ftp://ftp.labs.redhat.com/pub/imlib/"
AC_MSG_ERROR([Fatal Error: no Imlib detected.])])
AC_OUTPUT([
control-center.spec
Makefile
po/Makefile.in
control-center/Makefile
capplets/Makefile
capplets/mouse-properties/Makefile
capplets/mime-type/Makefile
capplets/keyboard-properties/Makefile
capplets/desktop-links/Makefile
capplets/background-properties/Makefile
capplets/screensaver-properties/Makefile
capplets/screensaver-properties/screensaver-desktops/Makefile
capplets/session-properties/Makefile
capplets/sound-properties/Makefile
capplets/bell-properties/Makefile
capplets/theme-switcher/Makefile
capplets/ui-properties/Makefile
capplets/url-properties/Makefile
capplets/gnome-edit-properties/Makefile
capplets/wm-properties/Makefile
capplets/wm-properties/wm-desktops/Makefile
idl/Makefile
intl/Makefile])

View File

@@ -1,135 +0,0 @@
# Note that this is NOT a relocatable package
%define ver @VERSION@
%define RELEASE 1
%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
%define prefix /usr
Summary: The GNOME control center.
Name: control-center
Version: %ver
Release: %rel
Copyright: LGPL
Group: System Environment/Libraries
Source: ftp://ftp.gnome.org/pub/control-center-%{ver}.tar.gz
BuildRoot: /var/tmp/control-center-%{PACKAGE_VERSION}-root
Obsoletes: gnome
URL: http://www.gnome.org
Docdir: %{prefix}/doc
Requires: xscreensaver >= 3.00
Requires: gnome-libs >= 1.0.0
Requires: ORBit >= 0.4.0
%description
Control-center is a configuration tool for easily
setting up your GNOME environment.
GNOME is the GNU Network Object Model Environment. That's
a fancy name, but really GNOME is a nice GUI desktop
environment.
It's a powerful, easy to configure environment which
helps to make your computer easy to use.
%package devel
Summary: GNOME control-center development files.
Group: System Environment/Libraries
Requires: control-center
%description devel
If you're interested in developing panels for the GNOME
control center, you'll want to install this package.
Control-center-devel helps you create the 'capplets'
which are used in the control center.
%changelog
* Sat Feb 27 1999 Gregory McLean <gregm@comstar.net>
- version 1.0.0
- updated the requirements to match the current released versions of packages.
- Added an alpha specfic rule as libtool don't understand _all_ alpha models.
* Mon Feb 15 1999 Michael Fulbright <drmike@redhat.com>
- version 0.99.8.1
- added etc/CORBA/servers/* to file list
* Fri Feb 12 1999 Michael Fulbright <drmike@redhat.com>
- update to 0.99.8
- added /usr/lib/cappletConf.sh
* Mon Feb 08 1999 The Rasterman <raster@redhat.com>
- update to 0.99.5.1
* Wed Feb 03 1999 Michael Fulbright <drmike@redhat.com>
- update to 0.99.5
* Mon Jan 20 1999 Michael Fulbright <drmike@redhat.com>
- update to 0.99.3.1
* Mon Jan 18 1999 Michael Fulbright <drmike@redhat.com>
- update to 0.99.3
- seems like patch for non-standard xscreensaver placement was already in
prestine sources(?)
* Wed Jan 06 1999 Jonathan Blandford <jrb@redhat.com>
- updated to 0.99.1
- temporary hack patch to get path to work to non-standard placement
of xscreensaver binaries in RH 5.2
* Wed Dec 16 1998 Jonathan Blandford <jrb@redhat.com>
- Created for the new control-center branch
%prep
%setup
%build
# libtool can't deal with all the alpha variations but and alpha is an alpha
# in this context.
%ifarch alpha
CFLAGS="$RPM_OPT_FLAGS" ./configure --host=alpha-redhat-linux --prefix=%prefix
%else
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix --sysconfdir=/etc
%endif
if [ ! -z "$SMP" ]; then
make -j$SMP MAKE="make -j$SMP"
else
make
fi
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc
make sysconfdir=$RPM_BUILD_ROOT/etc prefix=$RPM_BUILD_ROOT%{prefix} install
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog NEWS README
%{prefix}/bin/*
%{prefix}/lib/lib*.so.*
/etc/CORBA/servers/*
%{prefix}/share/control-center
%{prefix}/share/pixmaps/*
%{prefix}/share/locale/*/*/*
%{prefix}/share/gnome/apps/Settings/*
%{prefix}/share/gnome/wm-properties/*
%files devel
%defattr(-, root, root)
%{prefix}/lib/lib*.so
%{prefix}/lib/*a
%{prefix}/lib/*Conf.sh
%{prefix}/share/idl
%{prefix}/include/*

View File

@@ -1,36 +0,0 @@
appicondir = $(datadir)/pixmaps
appicon_DATA = control-center.png
splashdir = $(datadir)/pixmaps
splash_DATA = ccsplash.png
sysdir = $(datadir)/gnome/apps/Settings
sys_DATA = gnomecc.desktop
INCLUDES = \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
-I$(top_srcdir)/intl -I$(top_builddir)/intl \
-I$(includedir) $(GNOME_INCLUDEDIR) \
-DVERSION=\""$(VERSION)"\" \
-DSETTINGS_DIR=\""$(sysdir)"\" \
-DPIXMAPS_DIR=\""$(appicondir)"\"
bin_PROGRAMS = gnomecc root-manager
gnomecc_SOURCES = \
main.c \
capplet-dir.c capplet-dir.h \
capplet-dir-window.c capplet-dir-window.h
gnomecc_LDADD = \
$(GNOME_LIBDIR) \
$(GNOMEUI_LIBS) \
$(INTLLIBS)
root_manager_SOURCES = \
root-manager.c
root_manager_LDADD = \
$(GNOME_LIBS)
EXTRA_DIST = gnomecc.desktop $(appicon_DATA) $(splash_DATA)

View File

@@ -1,201 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* capplet-dir-window.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "capplet-dir-window.h"
static void close_cb (GtkWidget *widget, CappletDirWindow *window);
static void help_cb (GtkWidget *widget, CappletDirWindow *window);
static void about_cb (GtkWidget *widget, CappletDirWindow *window);
static void select_cb (GtkWidget *widget,
gint arg1,
GdkEvent *event,
CappletDirWindow *window);
static void about_done_cb (GtkWidget *widget, gpointer user_data);
static guint window_count;
static GtkWidget *about;
static GnomeUIInfo file_menu[] = {
GNOMEUIINFO_MENU_CLOSE_ITEM (close_cb, NULL),
GNOMEUIINFO_END
};
static GnomeUIInfo help_menu[] = {
GNOMEUIINFO_ITEM_STOCK (N_("Help on control-center"),
N_("Help with the GNOME control-center."),
help_cb, GNOME_STOCK_PIXMAP_HELP),
GNOMEUIINFO_SEPARATOR,
GNOMEUIINFO_ITEM_STOCK (N_("About"),
N_("About the GNOME control-center."),
about_cb, GNOME_STOCK_MENU_ABOUT),
GNOMEUIINFO_END
};
static GnomeUIInfo menu_bar[] = {
GNOMEUIINFO_MENU_FILE_TREE (file_menu),
GNOMEUIINFO_MENU_HELP_TREE (help_menu),
GNOMEUIINFO_END
};
CappletDirWindow *capplet_dir_window_new (CappletDir *dir)
{
CappletDirWindow *window;
GtkWidget *swin;
GtkAdjustment *adjustment;
int i;
swin = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
adjustment = gtk_scrolled_window_get_vadjustment
(GTK_SCROLLED_WINDOW (swin));
window = g_new0 (CappletDirWindow, 1);
window->capplet_dir = dir;
window->app =
GNOME_APP (gnome_app_new ("control-center",
CAPPLET_DIR_ENTRY (dir)->label));
window->icon_list =
GNOME_ICON_LIST (gnome_icon_list_new (96, adjustment, 0));
gtk_container_add (GTK_CONTAINER (swin),
GTK_WIDGET (window->icon_list));
gnome_icon_list_freeze (window->icon_list);
for (i = 0; dir->entries[i]; i++)
gnome_icon_list_insert (window->icon_list, i,
dir->entries[i]->icon,
dir->entries[i]->label);
gnome_icon_list_thaw (window->icon_list);
gtk_widget_set_usize (GTK_WIDGET (window->app), 400, 300);
gtk_signal_connect (GTK_OBJECT (window->app), "destroy",
GTK_SIGNAL_FUNC (close_cb), window);
gtk_signal_connect (GTK_OBJECT (window->icon_list), "select-icon",
GTK_SIGNAL_FUNC (select_cb), window);
gnome_app_create_menus_with_data (window->app, menu_bar, window);
gnome_app_set_contents (window->app, swin);
gtk_widget_show_all (GTK_WIDGET (window->app));
window_count++;
return window;
}
void capplet_dir_window_destroy (CappletDirWindow *window)
{
if (!window->destroyed) {
window->destroyed = TRUE;
if (!GTK_OBJECT_DESTROYED (GTK_OBJECT (window->app)))
gtk_object_destroy (GTK_OBJECT (window->app));
g_free (window);
window_count--;
if (window_count == 0) gtk_main_quit ();
}
}
static void
close_cb (GtkWidget *widget, CappletDirWindow *window)
{
capplet_dir_window_destroy (window);
}
static void
help_cb (GtkWidget *widget, CappletDirWindow *window)
{
gchar *tmp;
tmp = gnome_help_file_find_file ("users-guide", "gcc.html");
if (tmp) {
gnome_help_goto (0, tmp);
g_free (tmp);
} else {
GtkWidget *mbox;
mbox = gnome_message_box_new
(_("No help is available/installed. Please " \
"make sure you\nhave the GNOME User's " \
"Guide installed on your system."),
GNOME_MESSAGE_BOX_ERROR, _("Close"), NULL);
gtk_widget_show (mbox);
}
}
static void
about_cb (GtkWidget *widget, CappletDirWindow *window)
{
static gchar *authors[] = {
"Bradford Hovinen <hovinen@helixcode.com>",
NULL
};
if (about == NULL) {
about = gnome_about_new
(_("GNOME Control Center"), VERSION,
"Copyright (C) 2000 Helix Code, Inc.\n",
(const gchar **) authors,
_("Desktop Properties manager."),
NULL);
gtk_signal_connect (GTK_OBJECT (about), "destroy",
about_done_cb, NULL);
}
gtk_widget_show (about);
}
static void
select_cb (GtkWidget *widget, gint arg1, GdkEvent *event,
CappletDirWindow *window)
{
if (event->type == GDK_2BUTTON_PRESS &&
((GdkEventButton *) event)->button == 1)
{
capplet_dir_entry_activate
(window->capplet_dir->entries[arg1]);
}
}
static void
about_done_cb (GtkWidget *widget, gpointer user_data)
{
gtk_widget_hide (about);
}

View File

@@ -1,46 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* capplet-dir-window.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifndef __CAPPLET_DIR_WINDOW
#define __CAPPLET_DIR_WINDOW
#include <gnome.h>
#include "capplet-dir.h"
#define CAPPLET_DIR_WINDOW(obj) ((CappletDirWindow *) obj)
struct _CappletDirWindow
{
CappletDir *capplet_dir;
GnomeApp *app;
GnomeIconList *icon_list;
gboolean destroyed;
};
CappletDirWindow *capplet_dir_window_new (CappletDir *dir);
void capplet_dir_window_destroy (CappletDirWindow *window);
#endif /* __CAPPLET_DIR_WINDOW */

View File

@@ -1,292 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* capplet-dir.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
#include "capplet-dir.h"
#include "capplet-dir-window.h"
static void capplet_activate (Capplet *capplet);
static void capplet_dir_activate (CappletDir *capplet_dir);
static void capplet_shutdown (Capplet *capplet);
static void capplet_dir_shutdown (CappletDir *capplet_dir);
static CappletDirEntry **read_entries (gchar *path);
static void start_capplet_through_root_manager (GnomeDesktopEntry *gde);
CappletDirEntry *
capplet_new (gchar *desktop_path)
{
Capplet *capplet;
CappletDirEntry *entry;
g_return_val_if_fail (desktop_path != NULL, NULL);
capplet = g_new0 (Capplet, 1);
entry = CAPPLET_DIR_ENTRY (capplet);
entry->type = TYPE_CAPPLET;
entry->entry = gnome_desktop_entry_load (desktop_path);
entry->label = entry->entry->name;
entry->icon = entry->entry->icon;
/* Don't continue if this is just the control center again */
if (!strcmp (entry->entry->exec[0], "gnomecc")) {
capplet_dir_entry_destroy (entry);
return NULL;
}
if (!entry->icon)
entry->icon = PIXMAPS_DIR "/control-center.png";
return entry;
}
CappletDirEntry *
capplet_dir_new (gchar *dir_path)
{
CappletDir *capplet_dir;
CappletDirEntry *entry;
gchar *desktop_path;
g_return_val_if_fail (dir_path != NULL, NULL);
desktop_path = g_concat_dir_and_file (dir_path, ".directory");
capplet_dir = g_new0 (CappletDir, 1);
entry = CAPPLET_DIR_ENTRY (capplet_dir);
entry->type = TYPE_CAPPLET_DIR;
entry->entry = gnome_desktop_entry_load (desktop_path);
g_free (desktop_path);
if (entry->entry) {
entry->label = entry->entry->name;
entry->icon = entry->entry->icon;
if (!entry->icon)
entry->icon = PIXMAPS_DIR "/control-center.png";
} else {
/* If the .directory file could not be found or read, abort */
g_free (capplet_dir);
return NULL;
}
capplet_dir->path = g_strdup (dir_path);
return entry;
}
void
capplet_dir_entry_destroy (CappletDirEntry *entry)
{
if (entry->type == TYPE_CAPPLET) {
capplet_shutdown (CAPPLET (entry));
} else {
capplet_dir_shutdown (CAPPLET_DIR (entry));
g_free (CAPPLET_DIR (entry)->path);
}
gnome_desktop_entry_free (entry->entry);
g_free (entry);
}
void
capplet_dir_entry_activate (CappletDirEntry *entry)
{
g_return_if_fail (entry != NULL);
if (entry->type == TYPE_CAPPLET)
capplet_activate (CAPPLET (entry));
else if (entry->type == TYPE_CAPPLET_DIR)
capplet_dir_activate (CAPPLET_DIR (entry));
else
g_assert_not_reached ();
}
void
capplet_dir_entry_shutdown (CappletDirEntry *entry)
{
if (entry->type == TYPE_CAPPLET)
capplet_shutdown (CAPPLET (entry));
else if (entry->type == TYPE_CAPPLET_DIR)
capplet_dir_shutdown (CAPPLET_DIR (entry));
else
g_assert_not_reached ();
}
static void
capplet_activate (Capplet *capplet)
{
GnomeDesktopEntry *entry;
entry = CAPPLET_DIR_ENTRY (capplet)->entry;
if (!strcmp (entry->exec[0], "root-manager"))
start_capplet_through_root_manager (entry);
else
gnome_desktop_entry_launch (entry);
}
static void
capplet_dir_activate (CappletDir *capplet_dir)
{
capplet_dir->entries = read_entries (capplet_dir->path);
capplet_dir->window = capplet_dir_window_new (capplet_dir);
}
static void
capplet_shutdown (Capplet *capplet)
{
/* Can't do much here ... :-( */
}
static void
capplet_dir_shutdown (CappletDir *capplet_dir)
{
int i;
if (capplet_dir->window)
capplet_dir_window_destroy (capplet_dir->window);
if (capplet_dir->entries) {
for (i = 0; capplet_dir->entries[i]; i++)
capplet_dir_entry_destroy
(capplet_dir->entries[i]);
g_free (capplet_dir->entries);
}
}
static CappletDirEntry **
read_entries (gchar *path)
{
DIR *parent_dir;
struct dirent *child_dir;
struct stat filedata;
GList *list_head, *list_tail;
CappletDirEntry *entry;
gchar *fullpath;
CappletDirEntry **entry_array;
int i;
parent_dir = opendir (path);
if (parent_dir == NULL)
return NULL;
list_head = list_tail = NULL;
while ((child_dir = readdir (parent_dir)) != NULL) {
if (child_dir->d_name[0] != '.') {
/* we check to see if it is interesting. */
fullpath = g_concat_dir_and_file (path,
child_dir->d_name);
if (stat (fullpath, &filedata) != -1) {
gchar* test;
entry = NULL;
if (S_ISDIR (filedata.st_mode)) {
entry = capplet_dir_new (fullpath);
} else {
test = rindex(child_dir->d_name, '.');
if (test &&
!strcmp (".desktop", test))
/* it's a .desktop file --
* it's interesting for sure! */
entry = capplet_new (fullpath);
}
if (entry) {
list_tail = g_list_append
(list_tail, entry);
if (!list_head)
list_head = list_tail;
else
list_tail = list_tail->next;
}
}
g_free (fullpath);
}
}
closedir (parent_dir);
/* Allocate the array and copy the list contents over */
entry_array = g_new0 (CappletDirEntry *,
g_list_length (list_head) + 1);
i = 0;
while (list_head) {
entry_array[i++] = list_head->data;
list_head = g_list_remove_link (list_head, list_head);
}
entry_array[i] = NULL;
return entry_array;
}
static void
start_capplet_through_root_manager (GnomeDesktopEntry *gde)
{
static FILE *output = NULL;
pid_t pid;
char *cmdline;
if (!output) {
gint pipe_fd[2];
pipe (pipe_fd);
pid = fork ();
if (pid == (pid_t) -1) {
g_error ("%s", g_strerror (errno));
}
else if (pid == 0) {
char *arg[2];
dup2 (pipe_fd[0], 0);
arg[0] = gnome_is_program_in_path ("root-manager");
arg[1] = NULL;
execv (arg[0], arg);
}
}
cmdline = g_strjoinv (" ", gde->exec + 1);
fprintf (output, "%s\n", cmdline);
g_free (cmdline);
}

View File

@@ -1,74 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* capplet-dir.h
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifndef __CAPPLET_DIR_H
#define __CAPPLET_DIR_H
#include <gnome.h>
#define CAPPLET_DIR_ENTRY(obj) ((CappletDirEntry *) obj)
#define CAPPLET_DIR(obj) ((CappletDir *) obj)
#define CAPPLET(obj) ((Capplet *) obj)
typedef struct _CappletDirEntry CappletDirEntry;
typedef struct _CappletDir CappletDir;
typedef struct _Capplet Capplet;
typedef struct _CappletDirWindow CappletDirWindow;
typedef enum {
TYPE_CAPPLET, TYPE_CAPPLET_DIR
} CappletEntryType;
struct _CappletDirEntry
{
CappletEntryType type;
GnomeDesktopEntry *entry;
gchar *label;
gchar *icon;
};
struct _CappletDir
{
CappletDirEntry entry;
gchar *path;
CappletDirEntry **entries;
CappletDirWindow *window;
};
struct _Capplet
{
CappletDirEntry entry;
};
CappletDirEntry *capplet_new (gchar *desktop_path);
CappletDirEntry *capplet_dir_new (gchar *dir_path);
void capplet_dir_entry_destroy (CappletDirEntry *entry);
void capplet_dir_entry_activate (CappletDirEntry *entry);
void capplet_dir_entry_shutdown (CappletDirEntry *entry);
void control_center_init (int *argc, char **argv);
#endif /* __CAPPLET_DIR_H */

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -1,56 +0,0 @@
[Desktop Entry]
Name=GNOME Control Center
Name[ca]=Centre de Control GNOME
Name[cs]=Øídící centrum Gnome
Name[da]=Kontrolcenter
Name[de]=GNOME-Kontrollzentrum
Name[en_GB]Gnome Control Centre
Name[es]=Centro de Control GNOME
Name[et]=Juhtpaneel
Name[fi]=GNOME-hallintakeskus
Name[fr]=Centre de contrôle GNOME
Name[gl]=Centro de Control de GNOME
Name[hu]=GNOME Vezérlõpult
Name[ja]=GNOME¥³¥ó¥È¥í¡¼¥ë¥»¥ó¥¿¡¼
Name[ko]=±×³ð Á¶Á¾ÆÇ
Name[lt]=GNOME Valdymo centras
Name[no]=GNOME kontrollsenter
Name[pl]=Centrum Sterowania GNOME
Name[pt]=Centro de Controlo GNOME
Name[pt_BR]=Centro de Controle GNOME
Name[ru]=ãÅÎÔÒ õÐÒÁ×ÌÅÎÉÑ GNOME
Name[sv]=GNOME Kontrollcenter
Name[tr]=Gnome Ayarlar Merkezi
Name[uk]=ãÅÎÔÒ ËÅÒÕ×ÁÎÎÑ GNOME
Name[wa]=Cente di contrôle di GNOME
Name[zh_TW.Big5]=GNOME ±±¨î¥x
Name[zh_CN.GB2312]=GNOME ¿ØÖÆÌ¨
Comment=The GNOME configuration tool.
Comment[ca]=La ferramenta de configuració de GNOME
Comment[cs]=Øídící centrum Gnome - úprava vzhledu, nastavení periférií atd.
Comment[da]=Gnomes konfigurationsværktøj
Comment[de]=Das Konfigurationswerkzeug für GNOME
Comment[es]=Herramienta de configuración del entorno GNOME
Comment[et]=GNOME kasutajaliidese häälestusprogramm
Comment[fi]=GNOME:n hallintatyökalu
Comment[fr]=Outil de configuration de GNOME.
Comment[gl]=A ferramenta de configuración de GNOME
Comment[hu]=GNOME konfiguráció
Comment[ja]=GNOME¤ÎÀßÄê¥Ä¡¼¥ë¤Ç¤¹
Comment[ko]=±×³ð ¼³Á¤ ÇÁ·Î±×·¥
Comment[lt]=GNOME aplinkos konfigûravimo árankis.
Comment[no]=Konfigurasjonsverktøy for GNOME
Comment[pl]=Narzêdzie do konfiguracji GNOME
Comment[pt]=A ferramenta de configuração GNOME.
Comment[pt_BR]=A ferramenta de configuração GNOME
Comment[ru]=óÒÅÄÓÔ×Ï ËÏÎÆÉÇÕÒÁÃÉÉ GNOME
Comment[sv]=Konfigurationsverktyg för GNOME
Comment[tr]=Gnome'un ayarlar merkezi
Comment[uk]=úÁӦ ËÏÎÆ¦ÇÕÒÕ×ÁÎÎÑ GNOME
Comment[wa]=L' usteye d' apontiaedje di GNOME
Comment[zh_TW.Big5]=¦UºØ GNOME ³]©w¤u¨ã
Comment[zh_CN.GB2312]=¸÷ÖÖ GNOME É趨¹¤¾ß
Icon=control-center.png
Exec=gnomecc
Terminal=0
Type=Application

View File

@@ -1,52 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* main.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gnome.h>
#include "capplet-dir.h"
int
main (int argc, char **argv)
{
CappletDirEntry *main_dir;
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
textdomain (PACKAGE);
gnome_init ("control-center", VERSION, argc, argv);
main_dir = capplet_dir_new (SETTINGS_DIR);
if (!main_dir)
g_error ("Could not find directory of control panels");
capplet_dir_entry_activate (main_dir);
gtk_main ();
return 0;
}

View File

@@ -1,77 +0,0 @@
/* -*- mode: c; style: linux -*- */
/* root-manager.c
* Copyright (C) 2000 Helix Code, Inc.
*
* Written by Bradford Hovinen (hovinen@helixcode.com)
*
* 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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <glib.h>
#include <libgnome/libgnome.h>
int
main (int argc, char **argv)
{
char *buffer, *tmp;
char **args;
gint buf_size = 1024;
pid_t pid;
if (argc > 1) {
execv (gnome_is_program_in_path (args[1]), argv + 1);
g_error ("%s", g_strerror (errno));
}
buffer = g_new (char, buf_size);
while (1) {
tmp = buffer;
fgets (tmp, 1023, stdin);
while (strlen (tmp) == 1023) {
buf_size *= 2;
buffer = g_renew (char, buffer, buf_size);
tmp += 1023;
fgets (tmp, 1023, stdin);
}
pid = fork ();
if (pid == (pid_t) -1) {
g_error ("%s", g_strerror (errno));
}
else if (pid == 0) {
buffer[strlen (buffer) - 1] = '\0';
args = g_strsplit (buffer, " ", -1);
printf ("Output: %s", args[0]);
execv (gnome_is_program_in_path (args[0]), args);
g_error ("%s", g_strerror (errno));
}
}
return 0;
}

View File

@@ -1,10 +0,0 @@
*.gmo
*.mo
Makefile
Makefile.in
Makefile.in.in
POTFILES
cat-id-tbl.c
control-center.pot
stamp-cat-id

View File

@@ -1,717 +0,0 @@
2000-08-02 Kjartan Maraas <kmaraas@gnome.org>
* no.po: Updated Norwegian translation.
2000-08-02 Takayuki KUSANO <AE5T-KSN@asahi-net.or.jp>
* ja.po: Updated Japanese translation.
2000-07-16 Pablo Saratxaga <pablo@mandrakesoft.com>
* el.po: Updated Greek file
2000-07-15 Robert Brady <rwb197@zepler.org>
* en_GB.po: Updated British translation.
2000-07-13 Valek Filippov <frob@df.ru>
* de.po: updated translation from Kai Lahmann (kl@linuxfaqs.de).
2000-06-12 Pauli Virtanen <pauli.virtanen@saunalahti.fi>
* fi.po: finnish update.
2000-05-22 Fellmann Joaquim <joaquim@hrnet.fr>
* fr.po: Updated French translation
2000-05-20 Valek Filippov <frob@df.ru>
* ru.po: updated russian translation.
2000-04-19 Pablo Saratxaga <pablo@mandrakesoft.com>
* da.po: Updated Danish file
* ca.po: Updated Catalan file
2000-04-16 Pablo Saratxaga <pablo@mandrakesoft.com>
* lt.po: Updated Lithuanian file
2000-04-15 Fatih Demir <kabalak@gmx.net>
* tr.po : Added it !
2000-04-11 Jesus Bravo Alvarez <jba@pobox.com>
* gl.po: Updated Galician translation from stable branch.
2000-04-07 Pablo Saratxaga <pablo@mandrakesoft.com>
* lt.po: Updated Lithuanian translation file
2000-04-05 Pablo Saratxaga <pablo@mandrakesoft.com>
* es.po: Updated Spanish file
2000-04-05 Dan Damian <dand@dnttm.ro>
* ro.po: Updated Romanian translation.
2000-04-04 Zbigniew Chyla <chyla@buy.pl>
* pl.po: Updated translation.
2000-03-4 Pauli Virtanen <pauli.virtanen@saunalahti.fi>
* fi.po: Updated Finnish translation.
2000-03-31 Spiros Papadimitriou <spapadim+@cs.cmu.edu>
* el.po: Updated Greek translation.
2000-03-29 Pablo Saratxaga <pablo@mandrakesoft.com>
* lt.po: Added Lithuanian file
* el.po,pl.po: small change to po header, so msgfmt -v works
2000-03-27 Karl EICHWALDER <ke@suse.de>
* de.po: Update.
2000-03-13 Alastair McKinstry <mckinstry@computer.org>
* ga.po: More translations.
2000-03-11 Alastair McKinstry <mckinstry@computer.org>
* ga.po: Updated Irish translation.
2000-02-27 Christopher R. Gabriel <cgabriel@firenze.linux.it>
* it.po: updated italian translation.
2000-01-31 Yuan-Chung Cheng <platin@linux.org.tw>
* zh_CN.GB2312.po: from TurboLinux Chinese Develop Team.
2000-01-23 Spiros Papadimitriou <spapadim+@cs.cmu.edu>
* el.po: Original Greek translation (missing a few msgs).
2000-01-03 Kjartan Maraas <kmaraas@online.no>
* update.sh: A little script that lets people
update the .pot file without makefiles etc.
1999-12-29 Zbigniew Chyla <chyla@alice.ci.pwr.wroc.pl>
* pl.po: Updated translation.
1999-11-26 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated Norwegian translation.
1999-11-06 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated Norwegian translation.
1999-11-01 Yuri Syrota <rasta@renome.rovno.ua>
* gl.po: Updated the galician translation
1999-10-31 Ruben Lopez <ryu@mundivia.es>
* gl.po: Updated the galician translation
1999-10-28 Yuri Syrota <rasta@renome.rovno.ua>
* uk.po: Added Ukrainian translation.
1999-10-24 Ruben Lopez <ryu@mundivia.es>
* gl.po: Added Galician translation.
1999-10-07 Rodrigo Stulzer Lopes <rodrigo@conectiva.com.br>
* pt_BR.po: Updated.
1999-10-07 Karl Eichwalder <ke@suse.de>
* de.po: update.
1999-10-06 Pablo Saratxaga <pablo@mandrakesoft.com>
* da.po: updated Danish language file
1999-10-05 Sergey Panov <sipan@mit.edu>
* ru.po: updated Russian language file
1999-10-05 Pablo Saratxaga <pablo@mandrakesoft.com>
* es.po: updated spanish language file
1999-10-05 Sergey Panov <sipan@mit.edu>
* ru.po: updated Russian language file
1999-10-01 Jonathan Blandford <jrb@redhat.com>
* da.po: added po file from <Birger Langkjer>
1999-10-01 Pablo Saratxaga <pablo@mandrakesoft.com>
* es.po: updated spanish language file
* da.po: updated danish language file
* nl.po,pl.po: minor fixes (added some \n in nl.po, enabled the
header in pl.po to allow msgfmt -v to give interesting output)
1999-09-30 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated Norwegian translation.
1999-09-30 Tomas Ogren <stric@ing.umu.se>
* sv.po: Updated.
1999-09-30 Rodrigo Stulzer Lopes <rodrigo@conectiva.com.br>
* pt_BR.po: Updated.
1999-09-29 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated Norwegian translation.
1999-09-29 Yukihiro Nakai <nacai@iname.com>
* ja.po: Update from Itani Eiichiro.
1999-09-28 Kjartan Maraas <kmaraas@online.no>
* ro.po: Added Romainan translation from Dan
Damian <dand@dnttm.ro>.
1999-09-27 Richard Hult <rhult@hem2.passagen.se>
* sv.po: Updated Swedish translation.
1999-09-27 Zbigniew Chyla <chyla@alice.ci.pwr.wroc.pl>
* pl.po: Updated translation.
1999-09-26 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-09-26 Anders Carlsson <andersca@gnu.org>
* sv.po: Updated swedish translation
1999-09-24 Rodrigo Stulzer Lopes <rodrigo@conectiva.com.br>
* pt_BR.po: included
1999-09-22 Vincent Renardias <vincent@ldsol.com>
* fr.po: Updated for 1.0.40.
1999-09-21 Karl Eichwalder <ke@suse.de>
* de.po: Update.
1999-09-21 Zbigniew Chyla <chyla@alice.ci.pwr.wroc.pl>
* pl.po: Updated translation.
1999-09-21 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* ko.po: Updated translation.
1999-09-20 Karl Eichwalder <ke@suse.de>
* de.po: Update.
1999-09-17 Lauris Kaplinski <lauris@ariman.ee>
* et.po: Added Estonian translation
1999-09-17 Anders Carlsson <anders.carlsson@tordata.se>
* sv.po: Updated translation
1999-09-17 Kjartan Maraas <kmaraas@online.no>
* da.po: Updated Danish translation from Kenneth
Christiansen <kenneth@ripen.dk>.
1999-09-13 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-09-14 Karl Eichwalder <ke@suse.de>
* de.po: Update.
1999-09-10 Zbigniew Chyla <chyla@alice.ci.pwr.wroc.pl>
* pl.po: Updated translation.
1999--09-08 Vincent Renardias <vincent@ldsol.com>
* Updated fr.po:
before: 283 translated messages, 13 fuzzy translations, 6 untranslated messages.
after: 302 translated messages.
1999-09-03 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-09-02 Yukihiro Nakai <nacai@iname.com>
* ja.po: Updated translation from ITANI Eiichiro.
1999-09-02 Zbigniew Chyla <chyla@alice.ci.pwr.wroc.pl>
* pl.po: Updated translation.
1999-08-31 Kjartan Maraas <kmaraas@online.no
* da.po: Updated translation from Birger Langkjer
<birger.langkjer@image.dk>
1999-08-25 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-08-23 Mikko Rauhala <mjr@iki.fi>
* fi.po: updated
1999-08-19 Pablo Saratxaga <srtxg@chanae.alphanet.ch>
* ca.po: added catalan language file from
al011097@alumail.uji.es (Vilata Balaguer Ivan)
1999-08-18 Pablo Saratxaga <srtxg@chanae.alphanet.ch>
* es.po: updated spanish translation
1999-08-18 Sergey Panov <sipan@mit.edu>
* ru.po: Updated translation(and a lot of work ahead :( ).
1999-08-16 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-08-15 Mikko Rauhala <mjr@iki.fi>
* fi.po: Updated.
1999-08-13 Vincent Renardias <vincent@ldsol.com>
* fr.po: Updated for 1.0.6.
1999-08-13 Changwoo RYU <cwryu@adam.kaist.ac.kr>
* ko.po: updated translation.
1999-08-12 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-08-10 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* ko.po: Updated translation.
1999-08-05 Richard Hult <rhult@hem2.passagen.se>
* sv.po: Updated translation slightly.
1999-08-05 Anders Carlsson <anders.carlsson@tordata.se>
* sv.po: Updated translation.
1999-08-04 Karsten Weiss <karsten@addx.au.s.shuttle.de>
* de.po: Updated translation.
1999-08-01 Tom Tromey <tromey@cygnus.com>
* POTFILES.in: Added session-properties/startup-programs.c.
1999-07-30 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-07-29 Matthias Warkus <mawa@iname.com>
* de.po: little update
1999-07-29 Owen Taylor <otaylor@redhat.com>
* Removed e-conf files from POTFILES.in. People:
*check* that the stuff you add here actually
gets built/distributed.
1999-07-24 Karsten Weiss <karsten@addx.au.s.shuttle.de>
* de.po: Updated translation.
1999-07-21 Vincent Renardias <vincent@ldsol.com>
* fr.po: Updated thanks to Thibaut's patch.
1999-07-18 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-07-01 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-06-26 Mikko Rauhala <mjr@iki.fi>
* fi.po: Finnish updates.
1999-06-23 Yukihiro Nakai <nacai@iname.com>
* ja.po: Japanese translation updated from ITANI EIICHIRO.
1999-06-16 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1999-06-04 Kjartan Maraas <kmaraas@online.no>
* en_GB.po: added british translation from Robert Brady.
1999-05-20 Yukihiro Nakai <nacai@iname.com>
* ja.po: Japanese translation updated from ITANI EIICHIRO.
1999-05-19 Matthias Warkus <mawa@iname.com>
* de.po: Massive update.
1999-05-12 Shooby Ban <bansz@szif.hu>
* hu.po: updated.
1999-05-05 Raja R Harinath <harinath@cs.umn.edu>
* no.po: Add `\n' to translation.
1999-05-05 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-05-05 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* POTFILES.in: Added `capplets/mime-type/mime-data.c',
`capplets/mime-type/mime-mime-info.c',
`capplets/mime-type/mime-type-capplet.c',
`capplets/mime-type/new-mime-window.c'.
1999-04-28 Ettore Perazzoli <ettore@comm2000.it>
* it.po: Updated.
* POTFILES.in: Silly me. Removed e-conf stuff.
1999-04-15 Yukihiro Nakai <nacai@iname.com>
* ja.po: Updated.
1999-04-14 Matthias Warkus <mawa@iname.com>
* de.po: Updated.
1999-04-13 bertrand <Bertrand.Guiheneuf@inria.fr>
* fr.po: update some french translations
1999-04-13 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-04-05 Mikko Rauhala <mjr@iki.fi>
* fi.po: Completed and updated translation.
1999-04-03 Ettore Perazzoli <ettore@comm2000.it>
* POTFILES.in: Added
`capplets/wm-properties/wm-properties-capplet.c',
`capplets/e-conf/e-conf.c', `capplets/e-conf/e-conf_file.c',
`capplets/e-conf/e-conf_filesel.c'.
1999-04-02 Ettore Perazzoli <ettore@comm2000.it>
* it.po: Updated translation.
1999-03-26 Kjartan Maraas <kmaraas@online.no>
* no.po: Updated translation.
1999-03-16 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1999-03-14 Shooby Ban <bansz@szif.hu>
* hu.po: updated hungarian translations
1999-02-25 Kjartan Maraas <kmaraas@fib.hl.no>
* no.po: Updated.
1999-02-23 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1999-02-15 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1999-02-06 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* POTFILES.in: Added
capplets/gnome-edit-properties/gnome-edit-properties.c.
1998-12-21 Yukihiro Nakai <Nakai@Abricot.co.jp>
* ja.po: Updated.
1998-12-19 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* ko.po: Updated for 0.99.
1998-12-12 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* POTFILES.in: Added control-center/capplet-manager.c,
capplets/ui-properties/ui-properties.c,
capplets/url-properties/url-properties.c,
capplets/background-properties/property-background.c
1998-12-11 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-12-10 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* .cvsignore: Change gnome-core.pot to control-center.pot.
* pt.po: Removed the translations from gnome-core.
1998-12-05 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-11-30 Tuomas Lukka <lukka@iki.fi>
* fi.po: updates
1998-11-24 Tuomas Lukka <lukka@iki.fi>
* fi.po: updates
1998-11-21 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* POTFILES.in: Added control-center and capplets files.
* pt.po: Updates.
1998-11-18 Tuomas Lukka <lukka@iki.fi>
* fi.po: make it compile (blush), patch from Richard Hult
1998-11-16 Tuomas Lukka <lukka@iki.fi>
* fi.po: some updates
1998-10-28 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-10-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-10-09 Federico Mena Quintero <federico@nuclecu.unam.mx>
* ja.po: Updated. Thanks to Yukihiro Nakai for the patches.
1998-09-22 Federico Mena Quintero <federico@nuclecu.unam.mx>
* POTFILES.in: Removed references to applets/freshapp, since it
not being distributed.
Removed references to applets/gkb.
Removed references to applets/slashapp.
Removed references to gemvt.
1998-09-15 Ville Hautam$Bdk(Bi <villeh@cs.joensuu.fi>
* fi.po: Updated.
1998-08-21 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-08-19 Martin Baulig <martin@home-of-linux.org>
* de.po: Merged with `gnome-core.pot'.
* es.po: Likewise.
* fr.po: Likewise.
* ga.po: Likewise.
* it.po: Likewise.
* ko.po: Likewise.
* no.po: Likewise.
* pt.po: Likewise.
* sv.po: Likewise.
1998-08-18 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-08-15 Martin Baulig <martin@home-of-linux.org>
* fi.po: Removed spurious `--2fHTh5uZTiUOsy+g--' - has this
file been corrupted ?
Sat Aug 15 10:14:38 1998 Tom Tromey <tromey@cygnus.com>
* sv.po: Removed spurious \n.
1998-08-07 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
1998-08-04 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
* POTFILES.in: Added `desktop-properties/property-screensaver.cc'.
1998-08-02 Raja R Harinath <harinath@cs.umn.edu>
* POTFILES.in: Remove applets/winlist/winlist.c,
gemvt/getopt.c, help-browser/toc.c, help-browser/toc-man.c.
* ja.po: Add `\n' to msgstr, to match msgid.
1998-08-01 Raja R Harinath <harinath@cs.umn.edu>
* de.po: Merged with `gnome-core.pot'.
* es.po: Likewise.
* fr.po: Likewise.
* ga.po: Likewise.
* it.po: Likewise.
* ko.po: Likewise.
* no.po: Likewise.
* pt.po: Likewise.
* sv.po: Likewise.
1998-07-25 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
* POTFILES.in: Added `panel/session.c' and organized it.
1998-07-24 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
* POTFILES.in: Added `gmenu/dialogs.c', `gmenu/edit.c',
`gmenu/gmenu.c', `gmenu/order.c' and `gmenu/tree.c'.
1998-07-23 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* POTFILES.in: Added panel/applet.c
* pt.po: Updated.
Sun Jul 19 23:47:57 1998 Tom Tromey <tromey@cygnus.com>
* POTFILES.in: Added session-properties.c.
1998-06-30 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* pt.po: Updated.
* POTFILES.in: Added 'desktop-properties/app-ui.c',
'desktop-properties/app-bell.c', 'desktop-properties/property-ui.c'
and 'desktop-properties/property-bell.c'.
1998-06-26 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* POTFILES.in: Added 'gnome-terminal/gnome-terminal.c'.
* pt.po: New file.
Thu Jun 11 23:38:18 1998 Tom Tromey <tromey@cygnus.com>
* it.po: Removed spurious \n.
1998-06-04 Federico Mena Quintero <federico@nuclecu.unam.mx>
* POTFILES.in: Removed netwatch as it is not being compiled.
Sun, 31 May 1998 20:37:24 +0200 Vincent Renardias <vincent@waw.com>
* fr.po: major update + corrected some typos.
1998-05-23 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
* POTFILES.in: Added 'applets/netload/netload.c' and
'applets/netload/properties.c'.
* de.po: Updated German translation.
1998-05-22 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
* POTFILES.in: Added 'applets/fish/fish.c' and
'applets/clock/clock.c'.
* de.po: Updated German translation.
Wed Apr 29 14:46:00 1998 Kjartan Maraas <kmaraas@fib.hl.no>
* no.po: Updated Norwegian translation.
Tue Mar 17 23:00:33 1998 George Lebl <jirka@5z.com>
* POTFILES.in: fixed the files after the applets move
1998-03-13 Carsten Schaar <nhadcasc@fs-maphy.uni-hannover.de>
* de.po: New file.
Sat Mar 7 12:07:28 1998 Tom Tromey <tromey@cygnus.com>
* POTFILES.in: Added gsm/main.c and gsm/save-session.c.
1998-03-04 Raja R Harinath <harinath@cs.umn.edu>
* POTFILES.in: Renamed panel/applet-lib.cc to
panel/libapplet/applet-lib.cc.
Tue, 24 Feb 1998 20:04:09 +0100 Vincent Renardias <vincent@waw.com>
* Added files to POTFILES.in:
desktop-properties/{main,app-mouse,app-keyboard,app-background}.c
panel/{panel_config_global,panel_config,menu,applet-lib}.{c,cc}
panel/logout/logout.c
* Updated fr.po consequently.
* Added translations for desktop-links/*.directory
Sun, 22 Feb 1998 18:27:32 +0100 Vincent Renardias <vincent@waw.com>
* fr.po: New file.
Mon Feb 16 08:39:03 KST 1998 Changwoo Ryu <cwryu@adam.kaist.ac.kr>
* ko.po: New file.

View File

@@ -1,33 +0,0 @@
capplets/background-properties/app-background.c
capplets/background-properties/property-background.c
capplets/bell-properties/bell-properties.c
capplets/gnome-edit-properties/gnome-edit-properties.c
capplets/keyboard-properties/keyboard-properties.c
capplets/mime-type/edit-window.c
capplets/mime-type/mime-data.c
capplets/mime-type/mime-info.c
capplets/mime-type/mime-type-capplet.c
capplets/mime-type/new-mime-window.c
capplets/mouse-properties/mouse-properties.c
capplets/screensaver-properties/callbacks.c
capplets/screensaver-properties/screensaver-dialog.c
capplets/screensaver-properties/screensaver-properties-capplet.c
capplets/session-properties/gsm-client-editor.c
capplets/session-properties/gsm-client-list.c
capplets/session-properties/gsm-client-row.c
capplets/session-properties/gsm-protocol.c
capplets/session-properties/session-properties.c
capplets/session-properties/startup-programs.c
capplets/sound-properties/sound-properties.c
capplets/theme-switcher/demo.c
capplets/theme-switcher/gui.c
capplets/theme-switcher/install.c
capplets/ui-properties/ui-properties.c
capplets/url-properties/url-properties.c
capplets/wm-properties/wm-properties-capplet.c
control-center/callbacks.c
control-center/capplet-manager.c
control-center/capplet-widget-libs.c
control-center/capplet-widget.c
control-center/corba-glue.c
control-center/main.c

Some files were not shown because too many files have changed in this diff Show More