1
/* -*- mode: c; style: linux -*- */
4
* Copyright (C) 2001 Ximian, Inc.
6
* Written by Bradford Hovinen <hovinen@ximian.com>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2, or (at your option)
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24
#ifndef __CAPPLET_UTIL_H
25
#define __CAPPLET_UTIL_H
28
#include <gconf/gconf.h>
29
#include <gconf/gconf-changeset.h>
31
/* Macros to make certain repetitive tasks a bit easier */
33
/* Print a debugging message */
35
#ifdef G_HAVE_ISO_VARARGS
36
# define DEBUG_MSG(str, ...) \
37
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "(%d:%s) " str, \
38
getpid (), G_GNUC_FUNCTION, __VA_ARGS__)
39
#elif defined(G_HAVE_GNUC_VARARGS)
40
# define DEBUG_MSG(str, args...) \
41
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "(%d:%s) " str, \
42
getpid (), G_GNUC_FUNCTION, args)
44
# define DEBUG_MSG(str, args...)
47
/* Retrieve a widget from the Glade object */
49
#define WID(s) glade_xml_get_widget (dialog, s)
51
/* Copy a setting from the legacy gnome-config settings to the ConfigDatabase */
53
#define COPY_FROM_LEGACY(type, key, legacy_key) \
54
val_##type = gnome_config_get_##type##_with_default (legacy_key, &def); \
57
gconf_client_set_##type (client, key, val_##type, NULL);
59
/* Callback to apply the settings in the given database */
60
typedef void (*ApplySettingsFn) (void);
62
/* Callback to set up the dialog proper */
63
typedef GtkWidget *(*CreateDialogFn) (void);
65
/* Callback to set up property editors for the dialog */
66
typedef void (*SetupPropertyEditorsFn) (GtkWidget *dialog, GConfChangeSet *changeset);
68
/* Callback to retrieve legacy settings and store them in the new configuration
70
typedef void (*GetLegacySettingsFn) (void);
72
/* Set up the session management so that this capplet will apply its
73
* settings on every startup
76
void setup_session_mgmt (const gchar *binary_name);
78
/* Wrapper function for the entire capplet. This handles all initialization and
79
* runs the capplet for you. Just supply the appropriate callbacks and your argc
80
* and argv from main()
82
* This function makes several assumptions, requiring that all capplets follow a
83
* particular convention. In particular, suppose the name of the capplet binary
84
* is foo-properties-capplet. Then:
86
* - The factory IID is Bonobo_Control_Capplet_foo_properties_Factory
87
* - The default configuration moniker is archiver:foo-properties
89
* Following this convention yields capplets that are more uniform and thus
90
* easier to maintain, and simplifies the interfaces quite a bit. All capplet in
91
* this package are required to follow this convention.
94
void capplet_init (int argc,
96
ApplySettingsFn apply_fn,
97
CreateDialogFn create_dialog_fn,
98
SetupPropertyEditorsFn setup_property_editors_fn,
99
GetLegacySettingsFn get_legacy_settings_fn);
101
void capplet_error_dialog (GtkWindow *parent, char const *msg, GError *err);
102
void capplet_help (GtkWindow *parent, char const *helpfile, char const *section);
103
void capplet_set_icon (GtkWidget *window, char const *icon_file_name);
105
#endif /* __CAPPLET_UTIL_H */