Remove IMLIB check (GNOMECC_CAPPLETS_DESKTOP_IN_RULE): Add sed expression
2001-07-25 Bradford Hovinen <hovinen@ximian.com> * configure.in: Remove IMLIB check (GNOMECC_CAPPLETS_DESKTOP_IN_RULE): Add sed expression to cover macro DESKTOP_EXEC_LINE (LIBCOMMON_DIR): Add option --enable-bonobo-conf * all: Added support for optionally compiling without bonobo-conf enabled
This commit is contained in:
parent
429b2504b3
commit
4937798114
28 changed files with 1681 additions and 446 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2001-07-25 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* configure.in: Remove IMLIB check
|
||||||
|
(GNOMECC_CAPPLETS_DESKTOP_IN_RULE): Add sed expression to cover
|
||||||
|
macro DESKTOP_EXEC_LINE
|
||||||
|
(LIBCOMMON_DIR): Add option --enable-bonobo-conf
|
||||||
|
|
||||||
|
* all: Added support for optionally compiling without bonobo-conf enabled
|
||||||
|
|
||||||
2001-07-25 Chema Celorio <chema@celorio.com>
|
2001-07-25 Chema Celorio <chema@celorio.com>
|
||||||
|
|
||||||
* configure.in (dnl): remove the sawfish dir
|
* configure.in (dnl): remove the sawfish dir
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#undef HAVE_LIBSM
|
#undef HAVE_LIBSM
|
||||||
#undef HAVE_PROGRAM_INVOCATION_SHORT_NAME
|
#undef HAVE_PROGRAM_INVOCATION_SHORT_NAME
|
||||||
#undef HAVE_PROGRAM_INVOCATION_NAME
|
#undef HAVE_PROGRAM_INVOCATION_NAME
|
||||||
#undef HAVE_XIMIAN_ARCHIVER
|
#undef HAVE_BONOBO
|
||||||
|
|
||||||
#undef GNOMECC_ICONS_DIR
|
#undef GNOMECC_ICONS_DIR
|
||||||
#undef GNOMECC_GLADE_DIR
|
#undef GNOMECC_GLADE_DIR
|
||||||
|
|
|
@ -20,7 +20,14 @@ INCLUDES = \
|
||||||
@ARCHIVER_CFLAGS@ \
|
@ARCHIVER_CFLAGS@ \
|
||||||
@MONIKER_CFLAGS@
|
@MONIKER_CFLAGS@
|
||||||
|
|
||||||
bin_PROGRAMS = bonobo-moniker-archiver config-archiver
|
if MONIKER_ENABLE
|
||||||
|
BONOBO_MONIKER_ARCHIVER_BIN=bonobo-moniker-archiver
|
||||||
|
else
|
||||||
|
BONOBO_MONIKER_ARCHIVER_BIN=
|
||||||
|
endif
|
||||||
|
|
||||||
|
bin_PROGRAMS = $(BONOBO_MONIKER_ARCHIVER_BIN) config-archiver
|
||||||
|
|
||||||
lib_LTLIBRARIES = libconfig_archiver.la
|
lib_LTLIBRARIES = libconfig_archiver.la
|
||||||
|
|
||||||
libconfig_archiver_la_SOURCES = \
|
libconfig_archiver_la_SOURCES = \
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
always_built_SUBDIRS = \
|
always_built_SUBDIRS = \
|
||||||
common background keyboard mouse screensaver sound \
|
background keyboard mouse screensaver sound \
|
||||||
default-applications desktop-links
|
default-applications desktop-links
|
||||||
|
|
||||||
SUBDIRS = $(always_built_SUBDIRS)
|
SUBDIRS = $(always_built_SUBDIRS) $(LIBCOMMON_DIR)
|
||||||
|
|
||||||
EXTRA_DIST =
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2001-07-24 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* main.c (setup_dialog): Use bonobo_peditor_option_menu_construct
|
||||||
|
|
||||||
2001-07-25 Richard Hestilow <hestilow@ximian.com>
|
2001-07-25 Richard Hestilow <hestilow@ximian.com>
|
||||||
|
|
||||||
* main.c (setup_dialog): Hide opacity settings for now.
|
* main.c (setup_dialog): Hide opacity settings for now.
|
||||||
|
|
|
@ -3,11 +3,24 @@ cappletgroup =
|
||||||
bin_PROGRAMS = background-properties-capplet
|
bin_PROGRAMS = background-properties-capplet
|
||||||
|
|
||||||
background_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
background_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
||||||
background_properties_capplet_SOURCES = \
|
|
||||||
main.c\
|
bonobo_sources = \
|
||||||
applier.c applier.h
|
background-properties-capplet.c \
|
||||||
# prefs-widget.c prefs-widget.h \
|
applier.c applier.h
|
||||||
#preferences.c preferences.h \
|
|
||||||
|
legacy_sources = \
|
||||||
|
main.c \
|
||||||
|
applier.c applier.h \
|
||||||
|
prefs-widget.c prefs-widget.h \
|
||||||
|
preferences.c preferences.h
|
||||||
|
|
||||||
|
if BONOBO_CONF_ENABLE
|
||||||
|
DESKTOP_EXEC_LINE = gnomecc --run-capplet background-properties
|
||||||
|
background_properties_capplet_SOURCES = $(bonobo_sources)
|
||||||
|
else
|
||||||
|
DESKTOP_EXEC_LINE = background-properties-capplet
|
||||||
|
background_properties_capplet_SOURCES = $(legacy_sources)
|
||||||
|
endif
|
||||||
|
|
||||||
pixmap_DATA =
|
pixmap_DATA =
|
||||||
|
|
||||||
|
@ -27,7 +40,7 @@ oaffile = $(oaf_DATA)
|
||||||
|
|
||||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
||||||
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
||||||
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in
|
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in $(bonobo_sources) $(legacy_sources)
|
||||||
iconsdir = $(GNOMECC_ICONS_DIR)
|
iconsdir = $(GNOMECC_ICONS_DIR)
|
||||||
Gladedir = $(GNOMECC_GLADE_DIR)
|
Gladedir = $(GNOMECC_GLADE_DIR)
|
||||||
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
||||||
|
|
277
capplets/background/background-properties-capplet.c
Normal file
277
capplets/background/background-properties-capplet.c
Normal file
|
@ -0,0 +1,277 @@
|
||||||
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
|
/* main.c
|
||||||
|
* Copyright (C) 2000-2001 Ximian, Inc.
|
||||||
|
*
|
||||||
|
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
* Richard Hestilow <hestilow@ximian.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 <bonobo.h>
|
||||||
|
|
||||||
|
#include <glade/glade.h>
|
||||||
|
#include <gtk/gtksignal.h>
|
||||||
|
#include "capplet-util.h"
|
||||||
|
#include "applier.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
bonobo_config_set_filename (Bonobo_ConfigDatabase db,
|
||||||
|
const char *key,
|
||||||
|
const char *value,
|
||||||
|
CORBA_Environment *opt_ev);
|
||||||
|
|
||||||
|
static Applier *applier = NULL;
|
||||||
|
|
||||||
|
/* Popt option for compat reasons */
|
||||||
|
static gchar *background_image = NULL;
|
||||||
|
|
||||||
|
const struct poptOption options [] = {
|
||||||
|
{ "background-image", 'b', POPT_ARG_STRING, &background_image, 0,
|
||||||
|
N_("Set background image."), N_("IMAGE-FILE") },
|
||||||
|
{NULL, '\0', 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
apply_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
CORBA_Environment ev;
|
||||||
|
|
||||||
|
CORBA_exception_init (&ev);
|
||||||
|
if (!applier)
|
||||||
|
applier = APPLIER (applier_new ());
|
||||||
|
|
||||||
|
/* HAckity hackty */
|
||||||
|
if (background_image)
|
||||||
|
{
|
||||||
|
bonobo_config_set_filename (db, "/main/wallpaper_filename", background_image, NULL);
|
||||||
|
Bonobo_ConfigDatabase_sync (db, &ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
applier_apply_prefs (applier, CORBA_OBJECT_NIL, db, &ev, TRUE, FALSE);
|
||||||
|
CORBA_exception_free (&ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static CORBA_any*
|
||||||
|
gdk_color_to_bonobo (const gchar *colorstr)
|
||||||
|
{
|
||||||
|
GdkColor tmp;
|
||||||
|
CORBA_Environment ev;
|
||||||
|
DynamicAny_DynAny dyn;
|
||||||
|
CORBA_any *any;
|
||||||
|
|
||||||
|
g_return_val_if_fail (colorstr != NULL, NULL);
|
||||||
|
|
||||||
|
CORBA_exception_init (&ev);
|
||||||
|
|
||||||
|
gdk_color_parse (colorstr, &tmp);
|
||||||
|
|
||||||
|
dyn = CORBA_ORB_create_dyn_struct (bonobo_orb (),
|
||||||
|
TC_Bonobo_Config_Color, &ev);
|
||||||
|
|
||||||
|
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.red)/65535, &ev);
|
||||||
|
DynamicAny_DynAny_next (dyn, &ev);
|
||||||
|
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.green)/65535, &ev);
|
||||||
|
DynamicAny_DynAny_next (dyn, &ev);
|
||||||
|
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.blue)/65535, &ev);
|
||||||
|
DynamicAny_DynAny_next (dyn, &ev);
|
||||||
|
DynamicAny_DynAny_insert_double (dyn, 0, &ev);
|
||||||
|
|
||||||
|
any = DynamicAny_DynAny_to_any (dyn, &ev);
|
||||||
|
|
||||||
|
CORBA_Object_release ((CORBA_Object) dyn, &ev);
|
||||||
|
CORBA_exception_free (&ev);
|
||||||
|
|
||||||
|
return any;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
copy_color_from_legacy (Bonobo_ConfigDatabase db,
|
||||||
|
const gchar *key, const gchar *legacy_key)
|
||||||
|
{
|
||||||
|
gboolean def;
|
||||||
|
gchar *val_string;
|
||||||
|
|
||||||
|
g_return_if_fail (key != NULL);
|
||||||
|
g_return_if_fail (legacy_key != NULL);
|
||||||
|
|
||||||
|
val_string = gnome_config_get_string_with_default (legacy_key, &def);
|
||||||
|
|
||||||
|
if (!def)
|
||||||
|
{
|
||||||
|
CORBA_any *color = gdk_color_to_bonobo (val_string);
|
||||||
|
bonobo_config_set_value (db, key, color, NULL);
|
||||||
|
bonobo_arg_release (color);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (val_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bonobo_config_set_filename (Bonobo_ConfigDatabase db,
|
||||||
|
const char *key,
|
||||||
|
const char *value,
|
||||||
|
CORBA_Environment *opt_ev)
|
||||||
|
{
|
||||||
|
CORBA_any *any;
|
||||||
|
|
||||||
|
any = bonobo_arg_new (TC_Bonobo_Config_FileName);
|
||||||
|
*((CORBA_char **)(any->_value)) = CORBA_string_dup ((value)?(value):"");
|
||||||
|
bonobo_config_set_value (db, key, any, opt_ev);
|
||||||
|
bonobo_arg_release (any);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_legacy_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
gboolean val_boolean, def;
|
||||||
|
gchar *val_string, *val_filename;
|
||||||
|
int val_ulong, val_long;
|
||||||
|
|
||||||
|
COPY_FROM_LEGACY (filename, "/main/wallpaper_filename", string, "/Background/Default/wallpaper=none");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/wallpaper_type", int, "/Background/Default/wallpaperAlign=0");
|
||||||
|
copy_color_from_legacy (db, "/main/color1", "/Background/Default/color1");
|
||||||
|
copy_color_from_legacy (db, "/main/color2", "/Background/Default/color2");
|
||||||
|
|
||||||
|
/* Code to deal with new enum - messy */
|
||||||
|
val_ulong = -1;
|
||||||
|
val_string = gnome_config_get_string_with_default ("/Background/Default/simple=solid", &def);
|
||||||
|
if (!def)
|
||||||
|
{
|
||||||
|
if (!strcmp (val_string, "solid"))
|
||||||
|
val_ulong = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_free (val_string);
|
||||||
|
val_string = gnome_config_get_string_with_default ("/Background/Default/gradient=vertical", &def);
|
||||||
|
if (!def)
|
||||||
|
val_ulong = !strcmp (val_string, "vertical");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (val_string);
|
||||||
|
|
||||||
|
if (val_ulong != -1)
|
||||||
|
bonobo_config_set_ulong (db, "/main/orientation", val_ulong, NULL);
|
||||||
|
|
||||||
|
val_boolean = gnome_config_get_bool_with_default ("/Background/Default/adjustOpacity=true", &def);
|
||||||
|
if (!def && val_boolean)
|
||||||
|
{
|
||||||
|
COPY_FROM_LEGACY (long, "/main/opacity", int, "/Background/Default/opacity=100");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
property_change_cb (BonoboListener *listener,
|
||||||
|
char *event_name,
|
||||||
|
CORBA_any *any,
|
||||||
|
CORBA_Environment *ev,
|
||||||
|
Bonobo_PropertyBag pb)
|
||||||
|
{
|
||||||
|
applier_apply_prefs (applier, pb, CORBA_OBJECT_NIL, ev, FALSE, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
realize_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
|
{
|
||||||
|
CORBA_Environment ev;
|
||||||
|
|
||||||
|
CORBA_exception_init (&ev);
|
||||||
|
applier_apply_prefs (applier, bag, CORBA_OBJECT_NIL, &ev, FALSE, TRUE);
|
||||||
|
CORBA_exception_free (&ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CUSTOM_CREATE_PEDITOR(type, corba_type, key, widget) \
|
||||||
|
{ \
|
||||||
|
BonoboPEditor *ed = BONOBO_PEDITOR \
|
||||||
|
(bonobo_peditor_##type##_construct (WID (widget))); \
|
||||||
|
bonobo_peditor_set_property (ed, bag, key, TC_##corba_type, NULL); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
|
{
|
||||||
|
BonoboPEditor *ed;
|
||||||
|
GladeXML *dialog;
|
||||||
|
|
||||||
|
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_option_menu_construct (WID ("color_option")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "orientation", TC_ulong, NULL);
|
||||||
|
|
||||||
|
CUSTOM_CREATE_PEDITOR (color, Bonobo_Config_Color, "color1", "colorpicker1");
|
||||||
|
CUSTOM_CREATE_PEDITOR (color, Bonobo_Config_Color, "color2", "colorpicker2");
|
||||||
|
CUSTOM_CREATE_PEDITOR (filename, Bonobo_Config_FileName, "wallpaper_filename", "image_fileentry");
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_option_menu_construct (WID ("image_option")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "wallpaper_type", TC_ulong, NULL);
|
||||||
|
|
||||||
|
CUSTOM_CREATE_PEDITOR (int_range, long, "opacity", "opacity_spin");
|
||||||
|
gtk_widget_hide (WID ("opacity_spin"));
|
||||||
|
gtk_widget_hide (WID ("opacity_label"));
|
||||||
|
|
||||||
|
bonobo_event_source_client_add_listener (bag, (BonoboListenerCallbackFn) property_change_cb,
|
||||||
|
NULL, NULL, bag);
|
||||||
|
|
||||||
|
gtk_signal_connect_after (GTK_OBJECT (applier_class_get_preview_widget ()), "realize", realize_cb, bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget*
|
||||||
|
create_dialog (void)
|
||||||
|
{
|
||||||
|
GtkWidget *holder;
|
||||||
|
GtkWidget *widget;
|
||||||
|
GladeXML *dialog;
|
||||||
|
|
||||||
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/background-properties.glade", "prefs_widget");
|
||||||
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||||
|
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||||
|
|
||||||
|
applier = APPLIER (applier_new ());
|
||||||
|
|
||||||
|
/* Minor GUI addition */
|
||||||
|
holder = WID ("preview_holder");
|
||||||
|
gtk_box_pack_start (GTK_BOX (holder),
|
||||||
|
applier_class_get_preview_widget (),
|
||||||
|
TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show_all (holder);
|
||||||
|
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
||||||
|
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
||||||
|
GTK_OBJECT (dialog));
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
const gchar* legacy_files[] = { "Background", NULL };
|
||||||
|
|
||||||
|
glade_gnome_init ();
|
||||||
|
gnomelib_register_popt_table (options, "background options");
|
||||||
|
|
||||||
|
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
||||||
|
|
||||||
|
gnome_window_icon_set_default_from_file
|
||||||
|
(GNOMECC_ICONS_DIR"/gnome-ccbackground.png");
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
_Name=Background
|
_Name=Background
|
||||||
_Comment=Configuration of the desktop's background
|
_Comment=Configuration of the desktop's background
|
||||||
Exec=gnomecc --run-capplet background-properties-capplet
|
Exec=@DESKTOP_EXEC_LINE@
|
||||||
Icon=gnome-ccbackground.png
|
Icon=gnome-ccbackground.png
|
||||||
Terminal=0
|
Terminal=0
|
||||||
Type=Application
|
Type=Application
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* -*- mode: c; style: linux -*- */
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
/* main.c
|
/* main.c
|
||||||
* Copyright (C) 2000-2001 Ximian, Inc.
|
* Copyright (C) 2000 Helix Code, Inc.
|
||||||
|
*
|
||||||
|
* Written by Bradford Hovinen (hovinen@helixcode.com)
|
||||||
*
|
*
|
||||||
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
|
||||||
* Richard Hestilow <hestilow@ximian.com>
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2, or (at your option)
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
@ -25,253 +25,289 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
#include <gnome.h>
|
#include <gnome.h>
|
||||||
#include <bonobo.h>
|
#include <libgnomeui/gnome-window-icon.h>
|
||||||
|
#include <tree.h>
|
||||||
|
#include <parser.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <glade/glade.h>
|
#include <glade/glade.h>
|
||||||
#include <gtk/gtksignal.h>
|
|
||||||
#include "capplet-util.h"
|
#include <capplet-widget.h>
|
||||||
#include "applier.h"
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
# include <ximian-archiver/archive.h>
|
||||||
|
# include <ximian-archiver/location.h>
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
#include "preferences.h"
|
||||||
|
#include "prefs-widget.h"
|
||||||
|
|
||||||
|
static Preferences *prefs;
|
||||||
|
static Preferences *old_prefs;
|
||||||
|
static PrefsWidget *prefs_widget;
|
||||||
|
|
||||||
|
static guint ok_handler_id;
|
||||||
|
static guint cancel_handler_id;
|
||||||
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
|
||||||
|
static Archive *archive;
|
||||||
|
static gboolean outside_location;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bonobo_config_set_filename (Bonobo_ConfigDatabase db,
|
store_archive_data (void)
|
||||||
const char *key,
|
|
||||||
const char *value,
|
|
||||||
CORBA_Environment *opt_ev);
|
|
||||||
|
|
||||||
static Applier *applier = NULL;
|
|
||||||
|
|
||||||
/* Popt option for compat reasons */
|
|
||||||
static gchar *background_image = NULL;
|
|
||||||
|
|
||||||
const struct poptOption options [] = {
|
|
||||||
{ "background-image", 'b', POPT_ARG_STRING, &background_image, 0,
|
|
||||||
N_("Set background image."), N_("IMAGE-FILE") },
|
|
||||||
{NULL, '\0', 0, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
apply_settings (Bonobo_ConfigDatabase db)
|
|
||||||
{
|
{
|
||||||
CORBA_Environment ev;
|
Location *location;
|
||||||
|
xmlDocPtr xml_doc;
|
||||||
CORBA_exception_init (&ev);
|
|
||||||
if (!applier)
|
|
||||||
applier = APPLIER (applier_new ());
|
|
||||||
|
|
||||||
/* HAckity hackty */
|
if (capplet_get_location () == NULL)
|
||||||
if (background_image)
|
location = archive_get_current_location (archive);
|
||||||
{
|
else
|
||||||
bonobo_config_set_filename (db, "/main/wallpaper_filename", background_image, NULL);
|
location = archive_get_location (archive,
|
||||||
Bonobo_ConfigDatabase_sync (db, &ev);
|
capplet_get_location ());
|
||||||
|
|
||||||
|
xml_doc = preferences_write_xml (prefs);
|
||||||
|
location_store_xml (location, "background-properties-capplet",
|
||||||
|
xml_doc, STORE_MASK_PREVIOUS);
|
||||||
|
xmlFreeDoc (xml_doc);
|
||||||
|
archive_close (archive);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
static void
|
||||||
|
ok_cb (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
if (!outside_location) {
|
||||||
|
preferences_save (prefs);
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
}
|
||||||
|
#else /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
|
preferences_save (prefs);
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id);
|
||||||
|
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id);
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs_widget));
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
store_archive_data ();
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cancel_cb (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
if (!outside_location) {
|
||||||
|
preferences_save (old_prefs);
|
||||||
|
preferences_apply_now (old_prefs);
|
||||||
|
}
|
||||||
|
#else /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
|
preferences_save (prefs);
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), ok_handler_id);
|
||||||
|
gtk_signal_disconnect (GTK_OBJECT (prefs_widget), cancel_handler_id);
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs_widget));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_capplet_widget (void)
|
||||||
|
{
|
||||||
|
preferences_freeze (prefs);
|
||||||
|
|
||||||
|
prefs_widget = PREFS_WIDGET (prefs_widget_new (prefs));
|
||||||
|
|
||||||
|
ok_handler_id =
|
||||||
|
gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok",
|
||||||
|
GTK_SIGNAL_FUNC (ok_cb), NULL);
|
||||||
|
cancel_handler_id =
|
||||||
|
gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel",
|
||||||
|
GTK_SIGNAL_FUNC (cancel_cb), NULL);
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (prefs_widget));
|
||||||
|
|
||||||
|
preferences_thaw (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_get_xml (void)
|
||||||
|
{
|
||||||
|
Preferences *prefs;
|
||||||
|
xmlDocPtr doc;
|
||||||
|
|
||||||
|
prefs = PREFERENCES (preferences_new ());
|
||||||
|
preferences_load (prefs);
|
||||||
|
doc = preferences_write_xml (prefs);
|
||||||
|
xmlDocDump (stdout, doc);
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_set_xml (gboolean apply_settings)
|
||||||
|
{
|
||||||
|
xmlDocPtr doc;
|
||||||
|
char buffer[16384];
|
||||||
|
GString *doc_str;
|
||||||
|
int t = 0;
|
||||||
|
|
||||||
|
fflush (stdin);
|
||||||
|
|
||||||
|
fcntl (fileno (stdin), F_SETFL, 0);
|
||||||
|
|
||||||
|
doc_str = g_string_new ("");
|
||||||
|
|
||||||
|
while ((t = read (fileno (stdin), buffer, sizeof (buffer) - 1)) != 0) {
|
||||||
|
buffer[t] = '\0';
|
||||||
|
g_string_append (doc_str, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
applier_apply_prefs (applier, CORBA_OBJECT_NIL, db, &ev, TRUE, FALSE);
|
if (doc_str->len > 0) {
|
||||||
CORBA_exception_free (&ev);
|
doc = xmlParseDoc (doc_str->str);
|
||||||
}
|
g_string_free (doc_str, TRUE);
|
||||||
|
|
||||||
static CORBA_any*
|
if (doc != NULL) {
|
||||||
gdk_color_to_bonobo (const gchar *colorstr)
|
prefs = preferences_read_xml (doc);
|
||||||
{
|
|
||||||
GdkColor tmp;
|
|
||||||
CORBA_Environment ev;
|
|
||||||
DynamicAny_DynAny dyn;
|
|
||||||
CORBA_any *any;
|
|
||||||
|
|
||||||
g_return_val_if_fail (colorstr != NULL, NULL);
|
|
||||||
|
|
||||||
CORBA_exception_init (&ev);
|
if (prefs != NULL) {
|
||||||
|
if (apply_settings) {
|
||||||
gdk_color_parse (colorstr, &tmp);
|
preferences_save (prefs);
|
||||||
|
preferences_apply_now (prefs);
|
||||||
dyn = CORBA_ORB_create_dyn_struct (bonobo_orb (),
|
}
|
||||||
TC_Bonobo_Config_Color, &ev);
|
|
||||||
|
|
||||||
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.red)/65535, &ev);
|
return;
|
||||||
DynamicAny_DynAny_next (dyn, &ev);
|
}
|
||||||
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.green)/65535, &ev);
|
else if (prefs != NULL) {
|
||||||
DynamicAny_DynAny_next (dyn, &ev);
|
return;
|
||||||
DynamicAny_DynAny_insert_double (dyn, ((double)tmp.blue)/65535, &ev);
|
}
|
||||||
DynamicAny_DynAny_next (dyn, &ev);
|
|
||||||
DynamicAny_DynAny_insert_double (dyn, 0, &ev);
|
|
||||||
|
|
||||||
any = DynamicAny_DynAny_to_any (dyn, &ev);
|
xmlFreeDoc (doc);
|
||||||
|
|
||||||
CORBA_Object_release ((CORBA_Object) dyn, &ev);
|
|
||||||
CORBA_exception_free (&ev);
|
|
||||||
|
|
||||||
return any;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
copy_color_from_legacy (Bonobo_ConfigDatabase db,
|
|
||||||
const gchar *key, const gchar *legacy_key)
|
|
||||||
{
|
|
||||||
gboolean def;
|
|
||||||
gchar *val_string;
|
|
||||||
|
|
||||||
g_return_if_fail (key != NULL);
|
|
||||||
g_return_if_fail (legacy_key != NULL);
|
|
||||||
|
|
||||||
val_string = gnome_config_get_string_with_default (legacy_key, &def);
|
|
||||||
|
|
||||||
if (!def)
|
|
||||||
{
|
|
||||||
CORBA_any *color = gdk_color_to_bonobo (val_string);
|
|
||||||
bonobo_config_set_value (db, key, color, NULL);
|
|
||||||
bonobo_arg_release (color);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (val_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
bonobo_config_set_filename (Bonobo_ConfigDatabase db,
|
|
||||||
const char *key,
|
|
||||||
const char *value,
|
|
||||||
CORBA_Environment *opt_ev)
|
|
||||||
{
|
|
||||||
CORBA_any *any;
|
|
||||||
|
|
||||||
any = bonobo_arg_new (TC_Bonobo_Config_FileName);
|
|
||||||
*((CORBA_char **)(any->_value)) = CORBA_string_dup ((value)?(value):"");
|
|
||||||
bonobo_config_set_value (db, key, any, opt_ev);
|
|
||||||
bonobo_arg_release (any);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
get_legacy_settings (Bonobo_ConfigDatabase db)
|
|
||||||
{
|
|
||||||
gboolean val_boolean, def;
|
|
||||||
gchar *val_string, *val_filename;
|
|
||||||
int val_ulong, val_long;
|
|
||||||
|
|
||||||
COPY_FROM_LEGACY (filename, "/main/wallpaper_filename", string, "/Background/Default/wallpaper=none");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/wallpaper_type", int, "/Background/Default/wallpaperAlign=0");
|
|
||||||
copy_color_from_legacy (db, "/main/color1", "/Background/Default/color1");
|
|
||||||
copy_color_from_legacy (db, "/main/color2", "/Background/Default/color2");
|
|
||||||
|
|
||||||
/* Code to deal with new enum - messy */
|
|
||||||
val_ulong = -1;
|
|
||||||
val_string = gnome_config_get_string_with_default ("/Background/Default/simple=solid", &def);
|
|
||||||
if (!def)
|
|
||||||
{
|
|
||||||
if (!strcmp (val_string, "solid"))
|
|
||||||
val_ulong = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_free (val_string);
|
|
||||||
val_string = gnome_config_get_string_with_default ("/Background/Default/gradient=vertical", &def);
|
|
||||||
if (!def)
|
|
||||||
val_ulong = !strcmp (val_string, "vertical");
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
g_critical ("No data to apply");
|
||||||
g_free (val_string);
|
|
||||||
|
|
||||||
if (val_ulong != -1)
|
|
||||||
bonobo_config_set_ulong (db, "/main/orientation", val_ulong, NULL);
|
|
||||||
|
|
||||||
val_boolean = gnome_config_get_bool_with_default ("/Background/Default/adjustOpacity=true", &def);
|
|
||||||
if (!def && val_boolean)
|
|
||||||
{
|
|
||||||
COPY_FROM_LEGACY (long, "/main/opacity", int, "/Background/Default/opacity=100");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
property_change_cb (BonoboListener *listener,
|
|
||||||
char *event_name,
|
|
||||||
CORBA_any *any,
|
|
||||||
CORBA_Environment *ev,
|
|
||||||
Bonobo_PropertyBag pb)
|
|
||||||
{
|
|
||||||
applier_apply_prefs (applier, pb, CORBA_OBJECT_NIL, ev, FALSE, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
realize_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|
||||||
{
|
|
||||||
CORBA_Environment ev;
|
|
||||||
|
|
||||||
CORBA_exception_init (&ev);
|
|
||||||
applier_apply_prefs (applier, bag, CORBA_OBJECT_NIL, &ev, FALSE, TRUE);
|
|
||||||
CORBA_exception_free (&ev);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CUSTOM_CREATE_PEDITOR(type, corba_type, key, widget) \
|
|
||||||
{ \
|
|
||||||
BonoboPEditor *ed = BONOBO_PEDITOR \
|
|
||||||
(bonobo_peditor_##type##_construct (WID (widget))); \
|
|
||||||
bonobo_peditor_set_property (ed, bag, key, TC_##corba_type, NULL); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
static void
|
|
||||||
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|
||||||
{
|
|
||||||
BonoboPEditor *ed;
|
|
||||||
GladeXML *dialog;
|
|
||||||
|
|
||||||
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("color_option")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "orientation", TC_ulong, NULL);
|
|
||||||
|
|
||||||
CUSTOM_CREATE_PEDITOR (color, Bonobo_Config_Color, "color1", "colorpicker1");
|
|
||||||
CUSTOM_CREATE_PEDITOR (color, Bonobo_Config_Color, "color2", "colorpicker2");
|
|
||||||
CUSTOM_CREATE_PEDITOR (filename, Bonobo_Config_FileName, "wallpaper_filename", "image_fileentry");
|
|
||||||
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("image_option")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "wallpaper_type", TC_ulong, NULL);
|
|
||||||
|
|
||||||
CUSTOM_CREATE_PEDITOR (int_range, long, "opacity", "opacity_spin");
|
|
||||||
gtk_widget_hide (WID ("opacity_spin"));
|
|
||||||
gtk_widget_hide (WID ("opacity_label"));
|
|
||||||
|
|
||||||
bonobo_event_source_client_add_listener (bag, property_change_cb,
|
|
||||||
NULL, NULL, bag);
|
|
||||||
|
|
||||||
gtk_signal_connect_after (GTK_OBJECT (applier_class_get_preview_widget ()), "realize", realize_cb, bag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget*
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
create_dialog (void)
|
|
||||||
|
static void
|
||||||
|
do_restore_from_defaults (void)
|
||||||
{
|
{
|
||||||
GtkWidget *holder;
|
prefs = PREFERENCES (preferences_new ());
|
||||||
GtkWidget *widget;
|
preferences_save (prefs);
|
||||||
GladeXML *dialog;
|
preferences_apply_now (prefs);
|
||||||
|
|
||||||
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/background-properties.glade", "prefs_widget");
|
|
||||||
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
|
||||||
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
|
||||||
|
|
||||||
applier = APPLIER (applier_new ());
|
|
||||||
|
|
||||||
/* Minor GUI addition */
|
|
||||||
holder = WID ("preview_holder");
|
|
||||||
gtk_box_pack_start (GTK_BOX (holder),
|
|
||||||
applier_class_get_preview_widget (),
|
|
||||||
TRUE, TRUE, 0);
|
|
||||||
gtk_widget_show_all (holder);
|
|
||||||
|
|
||||||
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
|
||||||
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
|
||||||
GTK_OBJECT (dialog));
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
const gchar* legacy_files[] = { "Background", NULL };
|
GnomeClient *client;
|
||||||
|
GnomeClientFlags flags;
|
||||||
glade_gnome_init ();
|
gint token, res;
|
||||||
gnomelib_register_popt_table (options, "background options");
|
gchar *restart_args[3];
|
||||||
|
|
||||||
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
||||||
|
textdomain (PACKAGE);
|
||||||
|
|
||||||
|
glade_gnome_init ();
|
||||||
|
res = gnome_capplet_init ("background-properties-capplet",
|
||||||
|
VERSION, argc, argv, NULL,
|
||||||
|
0, NULL);
|
||||||
|
|
||||||
|
if (res < 0) {
|
||||||
|
g_error ("Could not initialize the capplet.");
|
||||||
|
}
|
||||||
|
else if (res == 3) {
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
do_get_xml ();
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (res == 4) {
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
do_set_xml (TRUE);
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (res == 5) {
|
||||||
|
do_restore_from_defaults ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
client = gnome_master_client ();
|
||||||
|
flags = gnome_client_get_flags (client);
|
||||||
|
|
||||||
|
if (flags & GNOME_CLIENT_IS_CONNECTED) {
|
||||||
|
token = gnome_startup_acquire_token
|
||||||
|
("GNOME_BACKGROUND_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_window_icon_set_default_from_file
|
||||||
(GNOMECC_ICONS_DIR"/gnome-ccbackground.png");
|
(GNOMECC_ICONS_DIR"/gnome-ccbackground.png");
|
||||||
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
archive = ARCHIVE (archive_load (FALSE));
|
||||||
|
|
||||||
|
if (capplet_get_location () != NULL &&
|
||||||
|
strcmp (capplet_get_location (),
|
||||||
|
archive_get_current_location_id (archive)))
|
||||||
|
{
|
||||||
|
outside_location = TRUE;
|
||||||
|
do_set_xml (FALSE);
|
||||||
|
if (prefs == NULL) return -1;
|
||||||
|
preferences_freeze (prefs);
|
||||||
|
} else {
|
||||||
|
outside_location = FALSE;
|
||||||
|
prefs = PREFERENCES (preferences_new ());
|
||||||
|
preferences_load (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outside_location && (token || res == 1)) {
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
prefs = PREFERENCES (preferences_new ());
|
||||||
|
preferences_load (prefs);
|
||||||
|
|
||||||
|
if (token || res == 1)
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
if (!res) {
|
||||||
|
old_prefs = PREFERENCES (preferences_clone (prefs));
|
||||||
|
setup_capplet_widget ();
|
||||||
|
|
||||||
|
capplet_gtk_main ();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,5 @@ INCLUDES = \
|
||||||
noinst_LIBRARIES = libcommon.a
|
noinst_LIBRARIES = libcommon.a
|
||||||
|
|
||||||
libcommon_a_SOURCES = \
|
libcommon_a_SOURCES = \
|
||||||
capplet-util.c capplet-util.h
|
capplet-util.c capplet-util.h \
|
||||||
|
bonobo-property-editor-range.c bonobo-property-editor-range.h
|
||||||
|
|
70
capplets/common/bonobo-property-editor-range.c
Normal file
70
capplets/common/bonobo-property-editor-range.c
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#include <bonobo-conf/bonobo-property-editor.h>
|
||||||
|
#include <gtk/gtkrange.h>
|
||||||
|
#include <gtk/gtksignal.h>
|
||||||
|
#include <bonobo.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
changed_cb (GtkAdjustment *adj, BonoboPEditor *editor)
|
||||||
|
{
|
||||||
|
CORBA_Environment ev;
|
||||||
|
DynamicAny_DynAny dyn;
|
||||||
|
BonoboArg *arg;
|
||||||
|
gulong val;
|
||||||
|
|
||||||
|
CORBA_exception_init (&ev);
|
||||||
|
|
||||||
|
val = adj->value;
|
||||||
|
|
||||||
|
dyn = CORBA_ORB_create_basic_dyn_any (bonobo_orb (), TC_ulong, &ev);
|
||||||
|
DynamicAny_DynAny_insert_ulong (dyn, val, &ev);
|
||||||
|
|
||||||
|
if (BONOBO_EX (&ev) || dyn == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
arg = DynamicAny_DynAny_to_any (dyn, &ev);
|
||||||
|
bonobo_peditor_set_value (editor, arg, &ev);
|
||||||
|
|
||||||
|
bonobo_arg_release (arg);
|
||||||
|
CORBA_Object_release ((CORBA_Object) dyn, &ev);
|
||||||
|
CORBA_exception_free (&ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
adj_set_value_cb (BonoboPEditor *editor,
|
||||||
|
BonoboArg *value,
|
||||||
|
CORBA_Environment *ev)
|
||||||
|
{
|
||||||
|
GtkAdjustment *adj;
|
||||||
|
gulong v;
|
||||||
|
|
||||||
|
adj = gtk_range_get_adjustment (GTK_RANGE (bonobo_peditor_get_widget (editor)));
|
||||||
|
|
||||||
|
if (!bonobo_arg_type_is_equal (value->_type, TC_ulong, NULL))
|
||||||
|
return;
|
||||||
|
|
||||||
|
v = BONOBO_ARG_GET_GENERAL (value, TC_ulong, CORBA_unsigned_long, NULL);
|
||||||
|
|
||||||
|
gtk_signal_handler_block_by_func (GTK_OBJECT (adj), changed_cb,
|
||||||
|
editor);
|
||||||
|
|
||||||
|
gtk_adjustment_set_value (adj, v);
|
||||||
|
|
||||||
|
gtk_signal_handler_unblock_by_func (GTK_OBJECT (adj), changed_cb,
|
||||||
|
editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkObject* bonobo_peditor_range_construct (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
BonoboPEditor *editor;
|
||||||
|
GtkAdjustment *adj;
|
||||||
|
|
||||||
|
g_return_val_if_fail (widget != NULL, NULL);
|
||||||
|
g_return_val_if_fail (GTK_IS_RANGE (widget), NULL);
|
||||||
|
|
||||||
|
editor = bonobo_peditor_construct (widget, adj_set_value_cb, TC_ulong);
|
||||||
|
adj = gtk_range_get_adjustment (GTK_RANGE (widget));
|
||||||
|
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
|
||||||
|
GTK_SIGNAL_FUNC (changed_cb), editor);
|
||||||
|
|
||||||
|
return GTK_OBJECT (editor);
|
||||||
|
}
|
8
capplets/common/bonobo-property-editor-range.h
Normal file
8
capplets/common/bonobo-property-editor-range.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#ifndef __BONOBO_PROPERTY_RANGE_SCALE_H__
|
||||||
|
#define __BONOBO_PROPERTY_RANGE_SCALE_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkwidget.h>
|
||||||
|
|
||||||
|
GtkObject* bonobo_peditor_range_construct (GtkWidget *widget);
|
||||||
|
|
||||||
|
#endif /* __BONOBO_PROPERTY_RANGE_SCALE_H__ */
|
|
@ -4,10 +4,21 @@ bin_PROGRAMS = keyboard-properties
|
||||||
|
|
||||||
keyboard_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(XF86MISC_LIBS)
|
keyboard_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS) $(XF86MISC_LIBS)
|
||||||
|
|
||||||
keyboard_properties_SOURCES = \
|
bonobo_sources = \
|
||||||
main.c \
|
keyboard-properties.c
|
||||||
bonobo-property-editor-range.c \
|
|
||||||
bonobo-property-editor-range.h
|
legacy_sources = \
|
||||||
|
main.c \
|
||||||
|
prefs-widget.c prefs-widget.h \
|
||||||
|
preferences.c preferences.h
|
||||||
|
|
||||||
|
if BONOBO_CONF_ENABLE
|
||||||
|
DESKTOP_EXEC_LINE = gnomecc --run-capplet keyboard-properties
|
||||||
|
keyboard_properties_SOURCES = $(bonobo_sources)
|
||||||
|
else
|
||||||
|
DESKTOP_EXEC_LINE = keyboard-properties
|
||||||
|
keyboard_properties_SOURCES = $(legacy_sources)
|
||||||
|
endif
|
||||||
|
|
||||||
## this is not generic
|
## this is not generic
|
||||||
|
|
||||||
|
@ -29,7 +40,7 @@ oaf_DATA = Bonobo_Control_Capplet_keyboard_properties.oaf
|
||||||
|
|
||||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
||||||
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
||||||
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in
|
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in $(bonobo_sources) $(legacy_sources)
|
||||||
iconsdir = $(GNOMECC_ICONS_DIR)
|
iconsdir = $(GNOMECC_ICONS_DIR)
|
||||||
Gladedir = $(GNOMECC_GLADE_DIR)
|
Gladedir = $(GNOMECC_GLADE_DIR)
|
||||||
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
||||||
|
|
217
capplets/keyboard/keyboard-properties.c
Normal file
217
capplets/keyboard/keyboard-properties.c
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
|
/* main.c
|
||||||
|
* Copyright (C) 2000-2001 Ximian, Inc.
|
||||||
|
*
|
||||||
|
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
* Richard Hestilow <hestilow@ximian.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-util.h"
|
||||||
|
#include "bonobo-property-editor-range.h"
|
||||||
|
|
||||||
|
#include <glade/glade.h>
|
||||||
|
#include <libgnomeui/gnome-window-icon.h>
|
||||||
|
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
#include <X11/X.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
||||||
|
#include <X11/extensions/xf86misc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
apply_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
gboolean repeat, click;
|
||||||
|
int rate, delay, volume;
|
||||||
|
int bell_volume, bell_pitch, bell_duration;
|
||||||
|
|
||||||
|
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
||||||
|
XF86MiscKbdSettings kbdsettings;
|
||||||
|
#endif
|
||||||
|
XKeyboardControl kbdcontrol;
|
||||||
|
int event_base_return, error_base_return;
|
||||||
|
|
||||||
|
repeat = bonobo_config_get_boolean (db, "/main/repeat", NULL);
|
||||||
|
click = bonobo_config_get_boolean (db, "/main/click", NULL);
|
||||||
|
rate = bonobo_config_get_ulong (db, "/main/rate", NULL);
|
||||||
|
delay = bonobo_config_get_ulong (db, "/main/delay", NULL);
|
||||||
|
volume = bonobo_config_get_ulong (db, "/main/volume", NULL);
|
||||||
|
bell_volume = bonobo_config_get_ulong (db, "/main/bell_volume", NULL);
|
||||||
|
bell_pitch = bonobo_config_get_ulong (db, "/main/bell_pitch", NULL);
|
||||||
|
bell_duration = bonobo_config_get_ulong (db, "/main/bell_duration", NULL);
|
||||||
|
|
||||||
|
if (repeat) {
|
||||||
|
XAutoRepeatOn (GDK_DISPLAY ());
|
||||||
|
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
||||||
|
if (XF86MiscQueryExtension (GDK_DISPLAY (),
|
||||||
|
&event_base_return,
|
||||||
|
&error_base_return) == True)
|
||||||
|
{
|
||||||
|
kbdsettings.rate = rate;
|
||||||
|
kbdsettings.delay = delay;
|
||||||
|
XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings);
|
||||||
|
} else {
|
||||||
|
XAutoRepeatOff (GDK_DISPLAY ());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
XAutoRepeatOff (GDK_DISPLAY ());
|
||||||
|
}
|
||||||
|
|
||||||
|
kbdcontrol.key_click_percent =
|
||||||
|
click ? volume : 0;
|
||||||
|
kbdcontrol.bell_percent = bell_volume;
|
||||||
|
kbdcontrol.bell_pitch = bell_pitch;
|
||||||
|
kbdcontrol.bell_duration = bell_duration;
|
||||||
|
XChangeKeyboardControl (GDK_DISPLAY (), KBKeyClickPercent,
|
||||||
|
&kbdcontrol);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gulong
|
||||||
|
get_value_ulong (Bonobo_PropertyBag bag, const gchar *prop)
|
||||||
|
{
|
||||||
|
BonoboArg *arg;
|
||||||
|
gulong val;
|
||||||
|
|
||||||
|
arg = bonobo_property_bag_client_get_value_any (bag, prop, NULL);
|
||||||
|
val = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_unsigned_long, NULL);
|
||||||
|
bonobo_arg_release (arg);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
bell_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
|
{
|
||||||
|
XKeyboardState backup;
|
||||||
|
XKeyboardControl kbdcontrol;
|
||||||
|
|
||||||
|
XGetKeyboardControl (GDK_DISPLAY (), &backup);
|
||||||
|
|
||||||
|
kbdcontrol.bell_percent = get_value_ulong (bag, "bell_volume");
|
||||||
|
kbdcontrol.bell_pitch = get_value_ulong (bag, "bell_pitch");
|
||||||
|
kbdcontrol.bell_duration = get_value_ulong (bag, "bell_duration");
|
||||||
|
XChangeKeyboardControl (GDK_DISPLAY (),
|
||||||
|
KBBellPercent | KBBellPitch | KBBellDuration,
|
||||||
|
&kbdcontrol);
|
||||||
|
XBell (GDK_DISPLAY (), 0);
|
||||||
|
|
||||||
|
kbdcontrol.bell_percent = backup.bell_percent;
|
||||||
|
kbdcontrol.bell_pitch = backup.bell_pitch;
|
||||||
|
kbdcontrol.bell_duration = backup.bell_duration;
|
||||||
|
|
||||||
|
XChangeKeyboardControl (GDK_DISPLAY (),
|
||||||
|
KBBellPercent | KBBellPitch | KBBellDuration,
|
||||||
|
&kbdcontrol);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget*
|
||||||
|
create_dialog (void)
|
||||||
|
{
|
||||||
|
GladeXML *dialog;
|
||||||
|
GtkWidget *widget, *pixmap;
|
||||||
|
|
||||||
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/keyboard-properties.glade", "prefs_widget");
|
||||||
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||||
|
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||||
|
|
||||||
|
/* Minor GUI addition */
|
||||||
|
pixmap = gnome_stock_pixmap_widget (WID ("bell_test_button"),
|
||||||
|
GNOME_STOCK_PIXMAP_VOLUME);
|
||||||
|
gtk_box_pack_start (GTK_BOX (WID ("bell_test_holder")), pixmap,
|
||||||
|
TRUE, TRUE, 0);
|
||||||
|
gtk_widget_show_all (WID ("bell_test_button"));
|
||||||
|
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
||||||
|
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
||||||
|
GTK_OBJECT (dialog));
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
|
{
|
||||||
|
GladeXML *dialog;
|
||||||
|
BonoboPEditor *ed;
|
||||||
|
|
||||||
|
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
||||||
|
|
||||||
|
CREATE_PEDITOR (boolean, "repeat", "repeat_toggle");
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_option_menu_construct (WID ("delay_menu")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "delay", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_option_menu_construct (WID ("repeat_menu")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "rate", TC_ulong, NULL);
|
||||||
|
bonobo_peditor_set_guard (WID ("repeat_table"), bag, "repeat");
|
||||||
|
|
||||||
|
CREATE_PEDITOR (boolean, "click", "click_toggle");
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("click_volume_entry")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "volume", TC_ulong, NULL);
|
||||||
|
bonobo_peditor_set_guard (WID ("click_hbox"), bag, "click");
|
||||||
|
|
||||||
|
/* Bell properties */
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_volume_range")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "bell_volume", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_pitch_range")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "bell_pitch", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_duration_range")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "bell_duration", TC_ulong, NULL);
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (WID ("bell_test_button")),
|
||||||
|
"clicked", bell_cb, bag);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_legacy_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
gboolean val_boolean, def;
|
||||||
|
gulong val_ulong;
|
||||||
|
|
||||||
|
COPY_FROM_LEGACY (boolean, "/main/repeat", bool, "/Desktop/Keyboard/repeat=true");
|
||||||
|
COPY_FROM_LEGACY (boolean, "/main/click", bool, "/Desktop/Keyboard/click=true");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/rate", int, "/Desktop/Keyboard/rate=30");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/delay", int, "/Desktop/Keyboard/delay=500");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/volume", int, "/Desktop/Keyboard/clickvolume=0");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/bell_volume", int, "/Desktop/Bell/percent=50");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/bell_pitch", int, "/Desktop/Bell/pitch=50");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/bell_duration", int, "/Desktop/Bell/duration=100");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
const gchar* legacy_files[] = { "Desktop", NULL };
|
||||||
|
|
||||||
|
glade_gnome_init ();
|
||||||
|
|
||||||
|
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
||||||
|
|
||||||
|
gnome_window_icon_set_default_from_file
|
||||||
|
(GNOMECC_ICONS_DIR"keyboard-capplet.png.png");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
_Name=Keyboard
|
_Name=Keyboard
|
||||||
_Comment=Keyboard Properties
|
_Comment=Keyboard Properties
|
||||||
Exec=gnomecc --run-capplet keyboard-properties
|
Exec=@DESKTOP_EXEC_LINE@
|
||||||
Icon=gnome-cckeyboard.png
|
Icon=gnome-cckeyboard.png
|
||||||
Terminal=0
|
Terminal=0
|
||||||
Type=Application
|
Type=Application
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/* -*- mode: c; style: linux -*- */
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
/* main.c
|
/* main.c
|
||||||
* Copyright (C) 2000-2001 Ximian, Inc.
|
* Copyright (C) 2000 Helix Code, Inc.
|
||||||
|
*
|
||||||
|
* Written by Bradford Hovinen (hovinen@helixcode.com)
|
||||||
*
|
*
|
||||||
* Written by: Bradford Hovinen <hovinen@ximian.com>
|
|
||||||
* Richard Hestilow <hestilow@ximian.com>
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2, or (at your option)
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
@ -25,193 +25,276 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "capplet-util.h"
|
#include <gtk/gtk.h>
|
||||||
#include "bonobo-property-editor-range.h"
|
#include <gnome.h>
|
||||||
|
#include <libgnomeui/gnome-window-icon.h>
|
||||||
|
#include <tree.h>
|
||||||
|
#include <parser.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <glade/glade.h>
|
#include <glade/glade.h>
|
||||||
#include <libgnomeui/gnome-window-icon.h>
|
|
||||||
|
|
||||||
#include <gdk/gdkx.h>
|
#include <capplet-widget.h>
|
||||||
#include <X11/X.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
#include <X11/extensions/xf86misc.h>
|
# include <ximian-archiver/archive.h>
|
||||||
#endif
|
# include <ximian-archiver/location.h>
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
#include "preferences.h"
|
||||||
|
#include "prefs-widget.h"
|
||||||
|
|
||||||
|
static Preferences *prefs;
|
||||||
|
static Preferences *old_prefs;
|
||||||
|
static PrefsWidget *prefs_widget;
|
||||||
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
|
||||||
|
static Archive *archive;
|
||||||
|
static gboolean outside_location;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
apply_settings (Bonobo_ConfigDatabase db)
|
store_archive_data (void)
|
||||||
{
|
{
|
||||||
gboolean repeat, click;
|
Location *location;
|
||||||
int rate, delay, volume;
|
xmlDocPtr xml_doc;
|
||||||
int bell_volume, bell_pitch, bell_duration;
|
|
||||||
|
|
||||||
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
if (capplet_get_location () == NULL)
|
||||||
XF86MiscKbdSettings kbdsettings;
|
location = archive_get_current_location (archive);
|
||||||
#endif
|
else
|
||||||
XKeyboardControl kbdcontrol;
|
location = archive_get_location (archive,
|
||||||
int event_base_return, error_base_return;
|
capplet_get_location ());
|
||||||
|
|
||||||
repeat = bonobo_config_get_boolean (db, "/main/repeat", NULL);
|
xml_doc = preferences_write_xml (prefs);
|
||||||
click = bonobo_config_get_boolean (db, "/main/click", NULL);
|
location_store_xml (location, "keyboard-properties-capplet",
|
||||||
rate = bonobo_config_get_ulong (db, "/main/rate", NULL);
|
xml_doc, STORE_MASK_PREVIOUS);
|
||||||
delay = bonobo_config_get_ulong (db, "/main/delay", NULL);
|
xmlFreeDoc (xml_doc);
|
||||||
volume = bonobo_config_get_ulong (db, "/main/volume", NULL);
|
archive_close (archive);
|
||||||
bell_volume = bonobo_config_get_ulong (db, "/main/bell_volume", NULL);
|
}
|
||||||
bell_pitch = bonobo_config_get_ulong (db, "/main/bell_pitch", NULL);
|
|
||||||
bell_duration = bonobo_config_get_ulong (db, "/main/bell_duration", NULL);
|
|
||||||
|
|
||||||
if (repeat) {
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
XAutoRepeatOn (GDK_DISPLAY ());
|
|
||||||
#ifdef HAVE_X11_EXTENSIONS_XF86MISC_H
|
static void
|
||||||
if (XF86MiscQueryExtension (GDK_DISPLAY (),
|
ok_cb (GtkWidget *widget)
|
||||||
&event_base_return,
|
{
|
||||||
&error_base_return) == True)
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
{
|
if (!outside_location) {
|
||||||
kbdsettings.rate = rate;
|
preferences_save (prefs);
|
||||||
kbdsettings.delay = delay;
|
preferences_apply_now (prefs);
|
||||||
XF86MiscSetKbdSettings (GDK_DISPLAY (), &kbdsettings);
|
}
|
||||||
} else {
|
#else /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
XAutoRepeatOff (GDK_DISPLAY ());
|
preferences_save (old_prefs);
|
||||||
}
|
preferences_apply_now (old_prefs);
|
||||||
#endif
|
#endif /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
} else {
|
|
||||||
XAutoRepeatOff (GDK_DISPLAY ());
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
store_archive_data ();
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cancel_cb (GtkWidget *widget)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
if (!outside_location) {
|
||||||
|
preferences_save (old_prefs);
|
||||||
|
preferences_apply_now (old_prefs);
|
||||||
|
}
|
||||||
|
#else /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
|
preferences_save (old_prefs);
|
||||||
|
preferences_apply_now (old_prefs);
|
||||||
|
#endif /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_capplet_widget (void)
|
||||||
|
{
|
||||||
|
preferences_freeze (prefs);
|
||||||
|
|
||||||
|
prefs_widget = PREFS_WIDGET (prefs_widget_new (prefs));
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (prefs_widget), "ok",
|
||||||
|
GTK_SIGNAL_FUNC (ok_cb), NULL);
|
||||||
|
gtk_signal_connect (GTK_OBJECT (prefs_widget), "cancel",
|
||||||
|
GTK_SIGNAL_FUNC (cancel_cb), NULL);
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (prefs_widget));
|
||||||
|
|
||||||
|
preferences_thaw (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_get_xml (void)
|
||||||
|
{
|
||||||
|
Preferences *prefs;
|
||||||
|
xmlDocPtr doc;
|
||||||
|
|
||||||
|
prefs = PREFERENCES (preferences_new ());
|
||||||
|
preferences_load (prefs);
|
||||||
|
doc = preferences_write_xml (prefs);
|
||||||
|
xmlDocDump (stdout, doc);
|
||||||
|
gtk_object_destroy (GTK_OBJECT (prefs));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
do_set_xml (gboolean apply_settings)
|
||||||
|
{
|
||||||
|
xmlDocPtr doc;
|
||||||
|
char buffer[16384];
|
||||||
|
GString *doc_str;
|
||||||
|
int t = 0;
|
||||||
|
|
||||||
|
fflush (stdin);
|
||||||
|
|
||||||
|
fcntl (fileno (stdin), F_SETFL, 0);
|
||||||
|
|
||||||
|
doc_str = g_string_new ("");
|
||||||
|
|
||||||
|
while ((t = read (fileno (stdin), buffer, sizeof (buffer) - 1)) != 0) {
|
||||||
|
buffer[t] = '\0';
|
||||||
|
g_string_append (doc_str, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
kbdcontrol.key_click_percent =
|
if (doc_str->len > 0) {
|
||||||
click ? volume : 0;
|
doc = xmlParseDoc (doc_str->str);
|
||||||
kbdcontrol.bell_percent = bell_volume;
|
g_string_free (doc_str, TRUE);
|
||||||
kbdcontrol.bell_pitch = bell_pitch;
|
|
||||||
kbdcontrol.bell_duration = bell_duration;
|
if (doc != NULL) {
|
||||||
XChangeKeyboardControl (GDK_DISPLAY (), KBKeyClickPercent,
|
prefs = preferences_read_xml (doc);
|
||||||
&kbdcontrol);
|
|
||||||
|
if (prefs != NULL) {
|
||||||
|
if (apply_settings) {
|
||||||
|
preferences_save (prefs);
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (prefs != NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlFreeDoc (doc);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_critical ("No data to apply");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gulong
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
get_value_ulong (Bonobo_PropertyBag bag, const gchar *prop)
|
|
||||||
{
|
|
||||||
BonoboArg *arg;
|
|
||||||
gulong val;
|
|
||||||
|
|
||||||
arg = bonobo_property_bag_client_get_value_any (bag, prop, NULL);
|
|
||||||
val = BONOBO_ARG_GET_GENERAL (arg, TC_ulong, CORBA_unsigned_long, NULL);
|
|
||||||
bonobo_arg_release (arg);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bell_cb (GtkWidget *widget, Bonobo_PropertyBag bag)
|
do_restore_from_defaults (void)
|
||||||
{
|
{
|
||||||
XKeyboardState backup;
|
prefs = PREFERENCES (preferences_new ());
|
||||||
XKeyboardControl kbdcontrol;
|
preferences_save (prefs);
|
||||||
|
preferences_apply_now (prefs);
|
||||||
XGetKeyboardControl (GDK_DISPLAY (), &backup);
|
|
||||||
|
|
||||||
kbdcontrol.bell_percent = get_value_ulong (bag, "bell_volume");
|
|
||||||
kbdcontrol.bell_pitch = get_value_ulong (bag, "bell_pitch");
|
|
||||||
kbdcontrol.bell_duration = get_value_ulong (bag, "bell_duration");
|
|
||||||
XChangeKeyboardControl (GDK_DISPLAY (),
|
|
||||||
KBBellPercent | KBBellPitch | KBBellDuration,
|
|
||||||
&kbdcontrol);
|
|
||||||
XBell (GDK_DISPLAY (), 0);
|
|
||||||
|
|
||||||
kbdcontrol.bell_percent = backup.bell_percent;
|
|
||||||
kbdcontrol.bell_pitch = backup.bell_pitch;
|
|
||||||
kbdcontrol.bell_duration = backup.bell_duration;
|
|
||||||
|
|
||||||
XChangeKeyboardControl (GDK_DISPLAY (),
|
|
||||||
KBBellPercent | KBBellPitch | KBBellDuration,
|
|
||||||
&kbdcontrol);
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget*
|
|
||||||
create_dialog (void)
|
|
||||||
{
|
|
||||||
GladeXML *dialog;
|
|
||||||
GtkWidget *widget, *pixmap;
|
|
||||||
|
|
||||||
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/keyboard-properties.glade", "prefs_widget");
|
|
||||||
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
|
||||||
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
|
||||||
|
|
||||||
/* Minor GUI addition */
|
|
||||||
pixmap = gnome_stock_pixmap_widget (WID ("bell_test_button"),
|
|
||||||
GNOME_STOCK_PIXMAP_VOLUME);
|
|
||||||
gtk_box_pack_start (GTK_BOX (WID ("bell_test_holder")), pixmap,
|
|
||||||
TRUE, TRUE, 0);
|
|
||||||
gtk_widget_show_all (WID ("bell_test_button"));
|
|
||||||
|
|
||||||
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
|
||||||
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
|
||||||
GTK_OBJECT (dialog));
|
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
|
||||||
{
|
|
||||||
GladeXML *dialog;
|
|
||||||
BonoboPEditor *ed;
|
|
||||||
|
|
||||||
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
|
||||||
|
|
||||||
CREATE_PEDITOR (boolean, "repeat", "repeat_toggle");
|
|
||||||
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("delay_menu")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "delay", TC_ulong, NULL);
|
|
||||||
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_option_construct (0, WID ("repeat_menu")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "rate", TC_ulong, NULL);
|
|
||||||
bonobo_peditor_set_guard (WID ("repeat_table"), bag, "repeat");
|
|
||||||
|
|
||||||
CREATE_PEDITOR (boolean, "click", "click_toggle");
|
|
||||||
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("click_volume_entry")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "volume", TC_ulong, NULL);
|
|
||||||
bonobo_peditor_set_guard (WID ("click_hbox"), bag, "click");
|
|
||||||
|
|
||||||
/* Bell properties */
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_volume_range")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "bell_volume", TC_ulong, NULL);
|
|
||||||
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_pitch_range")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "bell_pitch", TC_ulong, NULL);
|
|
||||||
|
|
||||||
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("bell_duration_range")));
|
|
||||||
bonobo_peditor_set_property (ed, bag, "bell_duration", TC_ulong, NULL);
|
|
||||||
|
|
||||||
gtk_signal_connect (GTK_OBJECT (WID ("bell_test_button")),
|
|
||||||
"clicked", bell_cb, bag);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
get_legacy_settings (Bonobo_ConfigDatabase db)
|
|
||||||
{
|
|
||||||
gboolean val_boolean, def;
|
|
||||||
gulong val_ulong;
|
|
||||||
|
|
||||||
COPY_FROM_LEGACY (boolean, "/main/repeat", bool, "/Desktop/Keyboard/repeat=true");
|
|
||||||
COPY_FROM_LEGACY (boolean, "/main/click", bool, "/Desktop/Keyboard/click=true");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/rate", int, "/Desktop/Keyboard/rate=30");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/delay", int, "/Desktop/Keyboard/delay=500");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/volume", int, "/Desktop/Keyboard/clickvolume=0");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/bell_volume", int, "/Desktop/Bell/percent=50");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/bell_pitch", int, "/Desktop/Bell/pitch=50");
|
|
||||||
COPY_FROM_LEGACY (ulong, "/main/bell_duration", int, "/Desktop/Bell/duration=100");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
const gchar* legacy_files[] = { "Desktop", NULL };
|
GnomeClient *client;
|
||||||
|
GnomeClientFlags flags;
|
||||||
|
gint token, res;
|
||||||
|
gchar *restart_args[3];
|
||||||
|
|
||||||
|
bindtextdomain (PACKAGE, GNOMELOCALEDIR);
|
||||||
|
textdomain (PACKAGE);
|
||||||
|
|
||||||
glade_gnome_init ();
|
glade_gnome_init ();
|
||||||
|
res = gnome_capplet_init ("keyboard-properties-capplet",
|
||||||
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
VERSION, argc, argv, NULL,
|
||||||
|
0, NULL);
|
||||||
|
|
||||||
|
if (res < 0) {
|
||||||
|
g_error ("Could not initialize the capplet.");
|
||||||
|
}
|
||||||
|
else if (res == 3) {
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
do_get_xml ();
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (res == 4) {
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
do_set_xml (TRUE);
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (res == 5) {
|
||||||
|
do_restore_from_defaults ();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
client = gnome_master_client ();
|
||||||
|
flags = gnome_client_get_flags (client);
|
||||||
|
|
||||||
|
if (flags & GNOME_CLIENT_IS_CONNECTED) {
|
||||||
|
token = gnome_startup_acquire_token
|
||||||
|
("GNOME_KEYBOARD_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_window_icon_set_default_from_file
|
||||||
(GNOMECC_ICONS_DIR"keyboard-capplet.png.png");
|
(GNOMECC_ICONS_DIR"keyboard-capplet.png.png");
|
||||||
|
|
||||||
|
#ifdef HAVE_XIMIAN_ARCHIVER
|
||||||
|
archive = ARCHIVE (archive_load (FALSE));
|
||||||
|
|
||||||
|
if (capplet_get_location () != NULL &&
|
||||||
|
strcmp (capplet_get_location (),
|
||||||
|
archive_get_current_location_id (archive)))
|
||||||
|
{
|
||||||
|
outside_location = TRUE;
|
||||||
|
do_set_xml (FALSE);
|
||||||
|
if (prefs == NULL) return -1;
|
||||||
|
preferences_freeze (prefs);
|
||||||
|
} else {
|
||||||
|
outside_location = FALSE;
|
||||||
|
prefs = PREFERENCES (preferences_new ());
|
||||||
|
preferences_load (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outside_location && token) {
|
||||||
|
preferences_apply_now (prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* !HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
prefs = PREFERENCES (preferences_new ());
|
||||||
|
preferences_load (prefs);
|
||||||
|
if (token) preferences_apply_now (prefs);
|
||||||
|
|
||||||
|
#endif /* HAVE_XIMIAN_ARCHIVER */
|
||||||
|
|
||||||
|
if (!res) {
|
||||||
|
old_prefs = PREFERENCES (preferences_clone (prefs));
|
||||||
|
setup_capplet_widget ();
|
||||||
|
|
||||||
|
capplet_gtk_main ();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
21
capplets/mouse/Bonobo_Control_Capplet_mouse_properties.oaf
Normal file
21
capplets/mouse/Bonobo_Control_Capplet_mouse_properties.oaf
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<oaf_info>
|
||||||
|
|
||||||
|
<oaf_server iid="OAFIID:Bonobo_Control_Capplet_mouse_properties_Factory" type="exe" location="mouse-properties">
|
||||||
|
<oaf_attribute name="repo_ids" type="stringv">
|
||||||
|
<item value="IDL:GNOME/ObjectFactory:1.0"/>
|
||||||
|
</oaf_attribute>
|
||||||
|
|
||||||
|
<oaf_attribute name="name" type="string" value="Mouse properties capplet factory"/>
|
||||||
|
</oaf_server>
|
||||||
|
|
||||||
|
<oaf_server iid="OAFIID:Bonobo_Control_Capplet_mouse_properties" type="factory"
|
||||||
|
location="OAFIID:Bonobo_Control_Capplet_mouse_properties_Factory">
|
||||||
|
<oaf_attribute name="repo_ids" type="stringv">
|
||||||
|
<item value="IDL:Bonobo/PropertyControl:1.0"/>
|
||||||
|
<item value="IDL:Bonobo/Unknown:1.0"/>
|
||||||
|
</oaf_attribute>
|
||||||
|
|
||||||
|
<oaf_attribute name="name" type="string" value="Mouse properties capplet"/>
|
||||||
|
</oaf_server>
|
||||||
|
|
||||||
|
</oaf_info>
|
|
@ -4,6 +4,15 @@
|
||||||
(left_handed_selected_cb): Ditto.
|
(left_handed_selected_cb): Ditto.
|
||||||
(right_handed_selected_cb): Ditto.
|
(right_handed_selected_cb): Ditto.
|
||||||
|
|
||||||
|
2001-07-24 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* Makefile.am (pixmap_DATA): Fixed pixmap_DATA line to install
|
||||||
|
mouse pixmaps
|
||||||
|
|
||||||
|
Courtesy Stephen Browne <stephen.browne@sun.com>:
|
||||||
|
* mouse-properties-capplet.c: bonobo-conf rewrite
|
||||||
|
(setup_dialog): Use bonobo_peditor_option_radio_construct
|
||||||
|
|
||||||
2001-07-20 Chema Celorio <chema@celorio.com>
|
2001-07-20 Chema Celorio <chema@celorio.com>
|
||||||
|
|
||||||
* RELEASE : 1.5.0
|
* RELEASE : 1.5.0
|
||||||
|
|
|
@ -1,13 +1,32 @@
|
||||||
cappletname = mouse
|
cappletname = mouse
|
||||||
|
cappletgroup =
|
||||||
bin_PROGRAMS = mouse-properties-capplet
|
bin_PROGRAMS = mouse-properties-capplet
|
||||||
|
|
||||||
mouse_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
mouse_properties_capplet_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
||||||
mouse_properties_capplet_SOURCES = \
|
|
||||||
main.c\
|
bonobo_sources = \
|
||||||
prefs-widget.c prefs-widget.h \
|
mouse-properties-capplet.c
|
||||||
|
|
||||||
|
legacy_sources = \
|
||||||
|
main.c \
|
||||||
|
prefs-widget.c prefs-widget.h \
|
||||||
preferences.c preferences.h
|
preferences.c preferences.h
|
||||||
|
|
||||||
pixmaps_DATA = mouse-left.png mouse-right.png
|
if BONOBO_CONF_ENABLE
|
||||||
|
DESKTOP_EXEC_LINE = gnomecc --run-capplet mouse-properties
|
||||||
|
mouse_properties_capplet_SOURCES = $(bonobo_sources)
|
||||||
|
else
|
||||||
|
DESKTOP_EXEC_LINE = mouse-properties-capplet
|
||||||
|
mouse_properties_capplet_SOURCES = $(legacy_sources)
|
||||||
|
endif
|
||||||
|
|
||||||
|
pixmap_DATA = mouse-left.png mouse-right.png
|
||||||
|
|
||||||
|
defaultsdir= $(datadir)/control-center/defaults
|
||||||
|
defaults_DATA = mouse-properties.xml
|
||||||
|
|
||||||
|
oafdir = $(datadir)/oaf
|
||||||
|
oaf_DATA = Bonobo_Control_Capplet_mouse_properties.oaf
|
||||||
|
|
||||||
##
|
##
|
||||||
## You should not need to modify anything below this line
|
## You should not need to modify anything below this line
|
||||||
|
@ -17,12 +36,11 @@ pixmaps_DATA = mouse-left.png mouse-right.png
|
||||||
|
|
||||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
||||||
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
||||||
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) mouse-left.png mouse-right.png
|
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(oaf_DATA) $(defaults_DATA) $(bonobo_sources) $(legacy_sources)
|
||||||
iconsdir = $(GNOMECC_ICONS_DIR)
|
iconsdir = $(GNOMECC_ICONS_DIR)
|
||||||
Gladedir = $(GNOMECC_GLADE_DIR)
|
Gladedir = $(GNOMECC_GLADE_DIR)
|
||||||
pixmapsdir = $(GNOMECC_PIXMAPS_DIR)
|
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
||||||
Glade_DATA = $(cappletname)-properties.glade
|
Glade_DATA = $(cappletname)-properties.glade
|
||||||
icons_DATA = $(cappletname)-capplet.png
|
icons_DATA = $(cappletname)-capplet.png
|
||||||
desktop = $(cappletname).desktop
|
desktop = $(cappletname).desktop
|
||||||
all-local: $(desktop)
|
all-local: $(desktop)
|
||||||
|
|
||||||
|
|
192
capplets/mouse/gnome-mouse-properties.c
Normal file
192
capplets/mouse/gnome-mouse-properties.c
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
|
/* mouse-properties-capplet.c
|
||||||
|
* Copyright (C) 2001 Ximian, Inc.
|
||||||
|
*
|
||||||
|
* Written by Bradford Hovinen <hovinen@ximian.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-util.h"
|
||||||
|
#include "bonobo-property-editor-range.h"
|
||||||
|
|
||||||
|
#include <glade/glade.h>
|
||||||
|
|
||||||
|
/* Needed only for the mouse capplet */
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
|
/* Maximum number of mouse buttons we handle. */
|
||||||
|
#define MAX_BUTTONS 10
|
||||||
|
|
||||||
|
/* Half the number of acceleration levels we support. */
|
||||||
|
#define MAX_ACCEL 3
|
||||||
|
|
||||||
|
/* Maximum threshold we support. */
|
||||||
|
#define MAX_THRESH 7
|
||||||
|
|
||||||
|
/* apply_settings
|
||||||
|
*
|
||||||
|
* Apply the settings of the property bag. This function is per-capplet, though
|
||||||
|
* there are some cases where it does not do anything.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
apply_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
unsigned char buttons[MAX_BUTTONS], i;
|
||||||
|
int nbuttons, num, max, den;
|
||||||
|
ulong accel, threshold;
|
||||||
|
gboolean rtol;
|
||||||
|
|
||||||
|
rtol = bonobo_config_get_boolean (db, "/main/right-to-left", NULL);
|
||||||
|
|
||||||
|
nbuttons = XGetPointerMapping (GDK_DISPLAY (), buttons, MAX_BUTTONS);
|
||||||
|
max = MIN (nbuttons, 3);
|
||||||
|
for (i = 0; i < max; i++)
|
||||||
|
buttons[i] = rtol ? (max - i) : (i + 1);
|
||||||
|
|
||||||
|
XSetPointerMapping (GDK_DISPLAY (), buttons, nbuttons);
|
||||||
|
|
||||||
|
accel = bonobo_config_get_ulong (db, "/main/acceleration", NULL);
|
||||||
|
|
||||||
|
if (accel < MAX_ACCEL) {
|
||||||
|
num = 1;
|
||||||
|
den = MAX_ACCEL - accel;
|
||||||
|
} else {
|
||||||
|
num = accel - MAX_ACCEL + 1;
|
||||||
|
den = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
threshold = bonobo_config_get_ulong (db, "/main/threshold", NULL);
|
||||||
|
|
||||||
|
XChangePointerControl (GDK_DISPLAY (), True, True,
|
||||||
|
num, den, threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set_pixmap_file
|
||||||
|
*
|
||||||
|
* Load the given pixmap and put it in the given widget. FIXME: Should this be in libcommon?
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_pixmap_file (GtkWidget *widget, const gchar *filename)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
GdkPixmap *pixmap;
|
||||||
|
GdkBitmap *mask;
|
||||||
|
|
||||||
|
g_return_if_fail (widget != NULL);
|
||||||
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
|
g_return_if_fail (filename != NULL);
|
||||||
|
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file (filename);
|
||||||
|
|
||||||
|
if (pixbuf) {
|
||||||
|
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 100);
|
||||||
|
gtk_pixmap_set (GTK_PIXMAP (widget),
|
||||||
|
pixmap, mask);
|
||||||
|
gdk_pixbuf_unref (pixbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create_dialog
|
||||||
|
*
|
||||||
|
* Create the dialog box and return it as a GtkWidget
|
||||||
|
*/
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_dialog (void)
|
||||||
|
{
|
||||||
|
GladeXML *dialog;
|
||||||
|
GtkWidget *widget;
|
||||||
|
|
||||||
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/mouse-properties.glade", "prefs_widget");
|
||||||
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||||
|
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||||
|
|
||||||
|
set_pixmap_file (WID ("mouse_left_pixmap"), GNOMECC_PIXMAPS_DIR "/mouse-left.png");
|
||||||
|
set_pixmap_file (WID ("mouse_right_pixmap"), GNOMECC_PIXMAPS_DIR "/mouse-right.png");
|
||||||
|
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
||||||
|
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
||||||
|
GTK_OBJECT (dialog));
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* setup_dialog
|
||||||
|
*
|
||||||
|
* Set up the property editors for our dialog
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
|
{
|
||||||
|
GladeXML *dialog;
|
||||||
|
BonoboPEditor *ed;
|
||||||
|
GtkWidget *rbs[3];
|
||||||
|
|
||||||
|
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
||||||
|
|
||||||
|
rbs[0] = WID ("right_handed_select");
|
||||||
|
rbs[1] = WID ("left_handed_select");
|
||||||
|
rbs[2] = NULL;
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_option_radio_construct (rbs));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "right-to-left", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("acceleration_entry")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "acceleration", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("sensitivity_entry")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "threshold", TC_ulong, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get_legacy_settings
|
||||||
|
*
|
||||||
|
* Retrieve older gnome_config -style settings and store them in the
|
||||||
|
* configuration database.
|
||||||
|
*
|
||||||
|
* In most cases, it's best to use the COPY_FROM_LEGACY macro defined in
|
||||||
|
* capplets/common/capplet-util.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_legacy_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
gboolean val_boolean, def;
|
||||||
|
gulong val_ulong;
|
||||||
|
|
||||||
|
COPY_FROM_LEGACY (boolean, "/main/right-to-left", bool, "/Desktop/Mouse/right-to-left");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/acceleration", int, "/Desktop/Mouse/aceleration=4");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/threshold", int, "/Desktop/Mouse/threshold=4");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
const gchar *legacy_files[] = { "Desktop", NULL };
|
||||||
|
|
||||||
|
glade_gnome_init ();
|
||||||
|
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
192
capplets/mouse/mouse-properties-capplet.c
Normal file
192
capplets/mouse/mouse-properties-capplet.c
Normal file
|
@ -0,0 +1,192 @@
|
||||||
|
/* -*- mode: c; style: linux -*- */
|
||||||
|
|
||||||
|
/* mouse-properties-capplet.c
|
||||||
|
* Copyright (C) 2001 Ximian, Inc.
|
||||||
|
*
|
||||||
|
* Written by Bradford Hovinen <hovinen@ximian.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-util.h"
|
||||||
|
#include "bonobo-property-editor-range.h"
|
||||||
|
|
||||||
|
#include <glade/glade.h>
|
||||||
|
|
||||||
|
/* Needed only for the mouse capplet */
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
|
/* Maximum number of mouse buttons we handle. */
|
||||||
|
#define MAX_BUTTONS 10
|
||||||
|
|
||||||
|
/* Half the number of acceleration levels we support. */
|
||||||
|
#define MAX_ACCEL 3
|
||||||
|
|
||||||
|
/* Maximum threshold we support. */
|
||||||
|
#define MAX_THRESH 7
|
||||||
|
|
||||||
|
/* apply_settings
|
||||||
|
*
|
||||||
|
* Apply the settings of the property bag. This function is per-capplet, though
|
||||||
|
* there are some cases where it does not do anything.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
apply_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
unsigned char buttons[MAX_BUTTONS], i;
|
||||||
|
int nbuttons, num, max, den;
|
||||||
|
ulong accel, threshold;
|
||||||
|
gboolean rtol;
|
||||||
|
|
||||||
|
rtol = bonobo_config_get_boolean (db, "/main/right-to-left", NULL);
|
||||||
|
|
||||||
|
nbuttons = XGetPointerMapping (GDK_DISPLAY (), buttons, MAX_BUTTONS);
|
||||||
|
max = MIN (nbuttons, 3);
|
||||||
|
for (i = 0; i < max; i++)
|
||||||
|
buttons[i] = rtol ? (max - i) : (i + 1);
|
||||||
|
|
||||||
|
XSetPointerMapping (GDK_DISPLAY (), buttons, nbuttons);
|
||||||
|
|
||||||
|
accel = bonobo_config_get_ulong (db, "/main/acceleration", NULL);
|
||||||
|
|
||||||
|
if (accel < MAX_ACCEL) {
|
||||||
|
num = 1;
|
||||||
|
den = MAX_ACCEL - accel;
|
||||||
|
} else {
|
||||||
|
num = accel - MAX_ACCEL + 1;
|
||||||
|
den = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
threshold = bonobo_config_get_ulong (db, "/main/threshold", NULL);
|
||||||
|
|
||||||
|
XChangePointerControl (GDK_DISPLAY (), True, True,
|
||||||
|
num, den, threshold);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set_pixmap_file
|
||||||
|
*
|
||||||
|
* Load the given pixmap and put it in the given widget. FIXME: Should this be in libcommon?
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_pixmap_file (GtkWidget *widget, const gchar *filename)
|
||||||
|
{
|
||||||
|
GdkPixbuf *pixbuf;
|
||||||
|
GdkPixmap *pixmap;
|
||||||
|
GdkBitmap *mask;
|
||||||
|
|
||||||
|
g_return_if_fail (widget != NULL);
|
||||||
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||||
|
g_return_if_fail (filename != NULL);
|
||||||
|
|
||||||
|
pixbuf = gdk_pixbuf_new_from_file (filename);
|
||||||
|
|
||||||
|
if (pixbuf) {
|
||||||
|
gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 100);
|
||||||
|
gtk_pixmap_set (GTK_PIXMAP (widget),
|
||||||
|
pixmap, mask);
|
||||||
|
gdk_pixbuf_unref (pixbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create_dialog
|
||||||
|
*
|
||||||
|
* Create the dialog box and return it as a GtkWidget
|
||||||
|
*/
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
create_dialog (void)
|
||||||
|
{
|
||||||
|
GladeXML *dialog;
|
||||||
|
GtkWidget *widget;
|
||||||
|
|
||||||
|
dialog = glade_xml_new (GNOMECC_GLADE_DIR "/mouse-properties.glade", "prefs_widget");
|
||||||
|
widget = glade_xml_get_widget (dialog, "prefs_widget");
|
||||||
|
gtk_object_set_data (GTK_OBJECT (widget), "glade-data", dialog);
|
||||||
|
|
||||||
|
set_pixmap_file (WID ("mouse_left_pixmap"), GNOMECC_PIXMAPS_DIR "/mouse-left.png");
|
||||||
|
set_pixmap_file (WID ("mouse_right_pixmap"), GNOMECC_PIXMAPS_DIR "/mouse-right.png");
|
||||||
|
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (widget), "destroy",
|
||||||
|
GTK_SIGNAL_FUNC (gtk_object_destroy),
|
||||||
|
GTK_OBJECT (dialog));
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* setup_dialog
|
||||||
|
*
|
||||||
|
* Set up the property editors for our dialog
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup_dialog (GtkWidget *widget, Bonobo_PropertyBag bag)
|
||||||
|
{
|
||||||
|
GladeXML *dialog;
|
||||||
|
BonoboPEditor *ed;
|
||||||
|
GtkWidget *rbs[3];
|
||||||
|
|
||||||
|
dialog = gtk_object_get_data (GTK_OBJECT (widget), "glade-data");
|
||||||
|
|
||||||
|
rbs[0] = WID ("right_handed_select");
|
||||||
|
rbs[1] = WID ("left_handed_select");
|
||||||
|
rbs[2] = NULL;
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_option_radio_construct (rbs));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "right-to-left", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("acceleration_entry")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "acceleration", TC_ulong, NULL);
|
||||||
|
|
||||||
|
ed = BONOBO_PEDITOR (bonobo_peditor_range_construct (WID ("sensitivity_entry")));
|
||||||
|
bonobo_peditor_set_property (ed, bag, "threshold", TC_ulong, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get_legacy_settings
|
||||||
|
*
|
||||||
|
* Retrieve older gnome_config -style settings and store them in the
|
||||||
|
* configuration database.
|
||||||
|
*
|
||||||
|
* In most cases, it's best to use the COPY_FROM_LEGACY macro defined in
|
||||||
|
* capplets/common/capplet-util.h.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_legacy_settings (Bonobo_ConfigDatabase db)
|
||||||
|
{
|
||||||
|
gboolean val_boolean, def;
|
||||||
|
gulong val_ulong;
|
||||||
|
|
||||||
|
COPY_FROM_LEGACY (boolean, "/main/right-to-left", bool, "/Desktop/Mouse/right-to-left");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/acceleration", int, "/Desktop/Mouse/aceleration=4");
|
||||||
|
COPY_FROM_LEGACY (ulong, "/main/threshold", int, "/Desktop/Mouse/threshold=4");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
const gchar *legacy_files[] = { "Desktop", NULL };
|
||||||
|
|
||||||
|
glade_gnome_init ();
|
||||||
|
capplet_init (argc, argv, legacy_files, apply_settings, create_dialog, setup_dialog, get_legacy_settings);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
8
capplets/mouse/mouse-properties.xml
Normal file
8
capplets/mouse/mouse-properties.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<bonobo-config>
|
||||||
|
<section path="main">
|
||||||
|
<entry name="right-to-left" type="boolean" value="0"/>
|
||||||
|
<entry name="acceleration" type="ulong" value="3"/>
|
||||||
|
<entry name="threshold" type="ulong" value="3"/>
|
||||||
|
</section>
|
||||||
|
</bonobo-config>
|
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
_Name=Mouse
|
_Name=Mouse
|
||||||
_Comment=Mouse Properties
|
_Comment=Mouse Properties
|
||||||
Exec=mouse-properties-capplet
|
Exec=@DESKTOP_EXEC_LINE@
|
||||||
Icon=gnome-mouse.png
|
Icon=gnome-mouse.png
|
||||||
Terminal=0
|
Terminal=0
|
||||||
Type=Application
|
Type=Application
|
||||||
|
|
|
@ -3,11 +3,24 @@ cappletgroup =
|
||||||
bin_PROGRAMS = sound-properties
|
bin_PROGRAMS = sound-properties
|
||||||
|
|
||||||
sound_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
sound_properties_LDADD = $(GNOMECC_CAPPLETS_LIBS)
|
||||||
sound_properties_SOURCES = \
|
|
||||||
|
bonobo_sources = \
|
||||||
sound-properties-capplet.c
|
sound-properties-capplet.c
|
||||||
|
|
||||||
pixmap_DATA =
|
legacy_sources = \
|
||||||
|
main.c \
|
||||||
|
prefs-widget.c prefs-widget.h \
|
||||||
|
preferences.c preferences.h
|
||||||
|
|
||||||
|
if BONOBO_CONF_ENABLE
|
||||||
|
DESKTOP_EXEC_LINE = gnomecc --run-capplet sound-properties
|
||||||
|
sound_properties_SOURCES = $(bonobo_sources)
|
||||||
|
else
|
||||||
|
DESKTOP_EXEC_LINE = sound-properties
|
||||||
|
sound_properties_SOURCES = $(legacy_sources)
|
||||||
|
endif
|
||||||
|
|
||||||
|
pixmap_DATA =
|
||||||
|
|
||||||
##
|
##
|
||||||
## this is not generic
|
## this is not generic
|
||||||
|
@ -29,7 +42,7 @@ oaffile = $(oaf_DATA)
|
||||||
|
|
||||||
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
INCLUDES = $(GNOMECC_CAPPLETS_CFLAGS)
|
||||||
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES)
|
||||||
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in
|
EXTRA_DIST = $(GNOMECC_CAPPLETS_EXTRA_DIST) $(defaults_DATA) $(oaf_DATA).in $(bonobo_sources) $(legacy_sources)
|
||||||
iconsdir = $(GNOMECC_ICONS_DIR)
|
iconsdir = $(GNOMECC_ICONS_DIR)
|
||||||
Gladedir = $(GNOMECC_GLADE_DIR)
|
Gladedir = $(GNOMECC_GLADE_DIR)
|
||||||
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
pixmapdir = $(GNOMECC_PIXMAPS_DIR)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
_Name=Sound
|
_Name=Sound
|
||||||
_Comment=Configure GNOME's use of sound
|
_Comment=Configure GNOME's use of sound
|
||||||
Exec=gnomecc --run-capplet sound-properties-capplet
|
Exec=@DESKTOP_EXEC_LINE@
|
||||||
Icon=gnome-audio2.png
|
Icon=gnome-audio2.png
|
||||||
Terminal=0
|
Terminal=0
|
||||||
Type=Application
|
Type=Application
|
||||||
|
|
78
configure.in
78
configure.in
|
@ -68,14 +68,6 @@ fi
|
||||||
dnl session-properties
|
dnl session-properties
|
||||||
AM_CONDITIONAL(SESSION, test "$GNOME_HAVE_SM" = true)
|
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.])])
|
|
||||||
|
|
||||||
CFLAGS="-O2 -g -Wall $CFLAGS"
|
CFLAGS="-O2 -g -Wall $CFLAGS"
|
||||||
AC_SUBST(CFLAGS)
|
AC_SUBST(CFLAGS)
|
||||||
|
|
||||||
|
@ -98,16 +90,47 @@ dnl Check for pkg-config
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
|
|
||||||
|
|
||||||
|
dnl ==============================================
|
||||||
|
dnl Check for --enable-bonobo-conf option
|
||||||
|
dnl ==============================================
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(bonobo-conf,[ --enable-bonobo-conf Enable bonobo-conf support in the capplets],[
|
||||||
|
PKG_BONOBO_CHECK="bonobo bonobox"
|
||||||
|
PKG_BONOBO_CONF_CHECK="bonobo bonobo_conf >= 0.8"
|
||||||
|
bonobo_conf_enable=yes
|
||||||
|
libcommon_enable=yes
|
||||||
|
LIBCOMMON_DIR=common
|
||||||
|
moniker_enable=yes
|
||||||
|
AC_DEFINE(HAVE_BONOBO)
|
||||||
|
],[
|
||||||
|
PKG_BONOBO_CHECK=
|
||||||
|
PKG_BONOBO_CONF_CHECK=
|
||||||
|
bonobo_conf_enable=
|
||||||
|
libcommon_enable=
|
||||||
|
LIBCOMMON_DIR=
|
||||||
|
moniker_enable=
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_SUBST(LIBCOMMON_DIR)
|
||||||
|
|
||||||
|
AM_CONDITIONAL(BONOBO_CONF_ENABLE, test "x$bonobo_conf_enable" = "xyes")
|
||||||
|
AM_CONDITIONAL(LIBCOMMON_ENABLE, test "x$libcommon_enable" = "xyes")
|
||||||
|
AM_CONDITIONAL(MONIKER_ENABLE, test "x$moniker_enable" = "xyes")
|
||||||
|
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
dnl Check that we meet the dependencies
|
dnl Check that we meet the dependencies
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
capplet_modules="libcapplet >= 1.4.0 libglade-gnome gdk_pixbuf bonobo_conf >= 0.7 gdk_pixbuf_xlib gal > 0.8 $ARCHIVER_MODULE"
|
capplet_modules="libcapplet >= 1.4.0 libglade-gnome gdk_pixbuf gdk_pixbuf_xlib gal > 0.8"
|
||||||
PKG_CHECK_MODULES(CAPPLET, $capplet_modules)
|
PKG_CHECK_MODULES(CAPPLET, $capplet_modules $PKG_BONOBO_CONF_CHECK)
|
||||||
PKG_CHECK_MODULES(GNOMECC, gnomeui libglade xml gdk_pixbuf gnomecanvaspixbuf bonobo bonobox gtkhtml >= 0.9)
|
PKG_CHECK_MODULES(GNOMECC, gnomeui libglade xml gdk_pixbuf gnomecanvaspixbuf $PKG_BONOBO_CHECK gtkhtml >= 0.9)
|
||||||
PKG_CHECK_MODULES(RMHELPER, gnomeui gnomecanvaspixbuf)
|
PKG_CHECK_MODULES(RMHELPER, gnomeui gnomecanvaspixbuf)
|
||||||
PKG_CHECK_MODULES(ARCHIVER, bonobo bonobo_conf xml)
|
PKG_CHECK_MODULES(ARCHIVER, $PKG_BONOBO_CONF_CHECK xml)
|
||||||
PKG_CHECK_MODULES(MONIKER, bonobo bonobo_conf xml)
|
|
||||||
PKG_CHECK_MODULES(CONFIG_ARCHIVER, gnome xml)
|
PKG_CHECK_MODULES(CONFIG_ARCHIVER, gnome xml)
|
||||||
|
|
||||||
|
if test "x$moniker_enable" = "xyes"; then
|
||||||
|
PKG_CHECK_MODULES(MONIKER, $PKG_BONOBO_CONF_CHECK xml)
|
||||||
|
fi
|
||||||
|
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
dnl End: Check that we meet the dependencies
|
dnl End: Check that we meet the dependencies
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
|
@ -116,8 +139,19 @@ dnl ==============================================
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
dnl Define the main variables
|
dnl Define the main variables
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
GNOMECC_CAPPLETS_CFLAGS="${CAPPLET_CFLAGS} -I\$(top_srcdir)/intl -I\$(top_srcdir)/ -DG_LOG_DOMAIN=\"\\\"\$(cappletname)-properties\\\"\" -DGLADE_DATADIR=\"\\\"${datadir}/control-center\\\"\" -DGNOMELOCALEDIR=\"\\\"${datadir}/locale\\\"\" -I\$(top_srcdir)/capplets/common "
|
if test "x$libcommon_enable" = "xyes"; then
|
||||||
GNOMECC_CAPPLETS_LIBS="${CAPPLET_LIBS} \$(top_builddir)/capplets/common/libcommon.a"
|
COMMON_CFLAGS="-I\$(top_srcdir)/capplets/common"
|
||||||
|
COMMON_LIBS="\$(top_builddir)/capplets/common/libcommon.a"
|
||||||
|
else
|
||||||
|
COMMON_CFLAGS=
|
||||||
|
COMMON_LIBS=
|
||||||
|
fi
|
||||||
|
|
||||||
|
EXTRA_CFLAGS="-I\$(top_srcdir)/intl -I\$(top_srcdir)/ -DG_LOG_DOMAIN=\"\\\"\$(cappletname)-properties\\\"\" -DGNOMELOCALEDIR=\"\\\"${datadir}/locale\\\"\""
|
||||||
|
|
||||||
|
GNOMECC_CAPPLETS_CFLAGS="${CAPPLET_CFLAGS} ${EXTRA_CFLAGS} ${COMMON_CFLAGS}"
|
||||||
|
GNOMECC_CAPPLETS_LIBS="${CAPPLET_LIBS} ${COMMON_LIBS}"
|
||||||
|
|
||||||
GNOMECC_CAPPLETS_CLEANFILES="\$(desktop) \$(desktop).in"
|
GNOMECC_CAPPLETS_CLEANFILES="\$(desktop) \$(desktop).in"
|
||||||
GNOMECC_CAPPLETS_EXTRA_DIST="ChangeLog \$(desktop).in.in \$(cappletname)-capplet.png \$(cappletname)-properties.glade \$(pixmaps_DATA)"
|
GNOMECC_CAPPLETS_EXTRA_DIST="ChangeLog \$(desktop).in.in \$(cappletname)-capplet.png \$(cappletname)-properties.glade \$(pixmaps_DATA)"
|
||||||
|
|
||||||
|
@ -151,19 +185,13 @@ dnl End: Define the directories
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dnl Here is the new sed line that adds the full path to the Exec line :
|
|
||||||
dnl sed -e \"s#Icon=.\*#Icon=$(GNOMECC_ICONS_DIR)/${cappletname}-capplet.png#\" -e \"s#Exec=.\*#Exec=gnomecc --run-capplet ${bin_PROGRAMS}#\" < $< \> ${cappletname}.desktop.in\
|
|
||||||
dnl
|
|
||||||
dnl Chema
|
|
||||||
|
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
dnl Macro for the common code
|
dnl Macro for the common code
|
||||||
dnl ==============================================
|
dnl ==============================================
|
||||||
AC_DEFUN(AC_PROG_GNOMECC_CAPPLETS,
|
AC_DEFUN(AC_PROG_GNOMECC_CAPPLETS,
|
||||||
[
|
[
|
||||||
GNOMECC_CAPPLETS_DESKTOP_IN_RULE='$(desktop).in: \%.desktop.in: \%.desktop.in.in\
|
GNOMECC_CAPPLETS_DESKTOP_IN_RULE='$(desktop).in: \%.desktop.in: \%.desktop.in.in\
|
||||||
sed -e \"s#Icon=.\*#Icon=$(GNOMECC_ICONS_DIR)/${cappletname}-capplet.png#\" < $< \> ${cappletname}.desktop.in\
|
sed -e \"s#@DESKTOP_EXEC_LINE@#$(DESKTOP_EXEC_LINE)#\" -e \"s#Icon=.\*#Icon=$(GNOMECC_ICONS_DIR)/${cappletname}-capplet.png#\" < $< \> ${cappletname}.desktop.in\
|
||||||
\
|
\
|
||||||
install-data-local:\
|
install-data-local:\
|
||||||
$(mkinstalldirs) $(datadir)/control-center/capplets/$(cappletgroup)\
|
$(mkinstalldirs) $(datadir)/control-center/capplets/$(cappletgroup)\
|
||||||
|
@ -172,9 +200,15 @@ install-data-am: install-data-local'
|
||||||
GNOMECC_CAPPLETS_OAF_FILE_IN_RULE='$(oaffile): \%.oaf: \%.oaf.in\
|
GNOMECC_CAPPLETS_OAF_FILE_IN_RULE='$(oaffile): \%.oaf: \%.oaf.in\
|
||||||
sed -e "s#REPLACEME_PLIZ#$(bindir)/$(bin_PROGRAMS)#" < $< > ${oaffile}'
|
sed -e "s#REPLACEME_PLIZ#$(bindir)/$(bin_PROGRAMS)#" < $< > ${oaffile}'
|
||||||
AC_DIVERT_PUSH(AC_DIVERSION_SED)dnl
|
AC_DIVERT_PUSH(AC_DIVERSION_SED)dnl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s%@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@%[$]GNOMECC_CAPPLETS_DESKTOP_IN_RULE%g
|
s%@GNOMECC_CAPPLETS_DESKTOP_IN_RULE@%[$]GNOMECC_CAPPLETS_DESKTOP_IN_RULE%g
|
||||||
s%@GNOMECC_CAPPLETS_OAF_FILE_IN_RULE@%[$]GNOMECC_CAPPLETS_OAF_FILE_IN_RULE%g
|
s%@GNOMECC_CAPPLETS_OAF_FILE_IN_RULE@%[$]GNOMECC_CAPPLETS_OAF_FILE_IN_RULE%g
|
||||||
AC_DIVERT_POP()dnl
|
AC_DIVERT_POP()dnl
|
||||||
|
|
||||||
# Redirect the config.log output again, so that the ltconfig log is not
|
# Redirect the config.log output again, so that the ltconfig log is not
|
||||||
# clobbered by the next message.
|
# clobbered by the next message.
|
||||||
exec 5>>./config.log
|
exec 5>>./config.log
|
||||||
|
|
|
@ -202,11 +202,11 @@ capplet_activate (Capplet *capplet)
|
||||||
entry = CAPPLET_DIR_ENTRY (capplet)->entry;
|
entry = CAPPLET_DIR_ENTRY (capplet)->entry;
|
||||||
|
|
||||||
#warning FIXME: this should probably be root-manager-helper
|
#warning FIXME: this should probably be root-manager-helper
|
||||||
#if 0
|
#ifdef HAVE_BONOBO
|
||||||
if (!strncmp (entry->exec[0], "gnomecc", strlen ("gnomecc")))
|
if (!strncmp (entry->exec[0], "gnomecc", strlen ("gnomecc")))
|
||||||
capplet_control_launch (entry->exec[2], entry->name);
|
capplet_control_launch (entry->exec[2], entry->name);
|
||||||
#endif
|
#endif
|
||||||
if (!strncmp (entry->exec[0], "root-manager", strlen ("root-manager")))
|
else if (!strncmp (entry->exec[0], "root-manager", strlen ("root-manager")))
|
||||||
start_capplet_through_root_manager (entry);
|
start_capplet_through_root_manager (entry);
|
||||||
else
|
else
|
||||||
gnome_desktop_entry_launch (entry);
|
gnome_desktop_entry_launch (entry);
|
||||||
|
@ -422,6 +422,8 @@ capplet_cancel_cb (GtkWidget *widget, GtkWidget *app)
|
||||||
CORBA_exception_free (&ev);
|
CORBA_exception_free (&ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_BONOBO
|
||||||
|
|
||||||
/* capplet_control_launch
|
/* capplet_control_launch
|
||||||
*
|
*
|
||||||
* Launch a capplet as a Bonobo control; returns the relevant BonoboWindow or
|
* Launch a capplet as a Bonobo control; returns the relevant BonoboWindow or
|
||||||
|
@ -518,3 +520,5 @@ capplet_control_launch (const gchar *capplet_name, gchar *window_title)
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_BONOBO */
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#include "capplet-dir.h"
|
#include "capplet-dir.h"
|
||||||
#include "capplet-dir-view.h"
|
#include "capplet-dir-view.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_BONOBO
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
real_launch_control (gchar *capplet)
|
real_launch_control (gchar *capplet)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +55,8 @@ real_launch_control (gchar *capplet)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -60,8 +64,10 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
static gchar *capplet = NULL;
|
static gchar *capplet = NULL;
|
||||||
static struct poptOption gnomecc_options[] = {
|
static struct poptOption gnomecc_options[] = {
|
||||||
|
#ifdef HAVE_BONOBO
|
||||||
{ "run-capplet", '\0', POPT_ARG_STRING, &capplet, 0,
|
{ "run-capplet", '\0', POPT_ARG_STRING, &capplet, 0,
|
||||||
N_("Run the capplet CAPPLET"), N_("CAPPLET") },
|
N_("Run the capplet CAPPLET"), N_("CAPPLET") },
|
||||||
|
#endif
|
||||||
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,7 +86,9 @@ main (int argc, char **argv)
|
||||||
gconf_init (argc, argv, NULL);
|
gconf_init (argc, argv, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BONOBO
|
||||||
if (capplet == NULL) {
|
if (capplet == NULL) {
|
||||||
|
#endif
|
||||||
CappletDirEntry *entry;
|
CappletDirEntry *entry;
|
||||||
CappletDir *dir;
|
CappletDir *dir;
|
||||||
|
|
||||||
|
@ -92,9 +100,11 @@ main (int argc, char **argv)
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -1;
|
return -1;
|
||||||
capplet_dir_entry_activate (entry, NULL);
|
capplet_dir_entry_activate (entry, NULL);
|
||||||
|
#ifdef HAVE_BONOBO
|
||||||
} else {
|
} else {
|
||||||
gtk_idle_add ((GtkFunction) real_launch_control, capplet);
|
gtk_idle_add ((GtkFunction) real_launch_control, capplet);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bonobo_main ();
|
bonobo_main ();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue