~ubuntu-branches/ubuntu/trusty/brightside/trusty

« back to all changes in this revision

Viewing changes to src/capplet-util.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-03-14 12:55:57 UTC
  • Revision ID: james.westby@ubuntu.com-20050314125557-s7vle73vmcspbi8x
Tags: upstream-1.3.2
ImportĀ upstreamĀ versionĀ 1.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: c; style: linux -*- */
 
2
 
 
3
/* capplet-util.h
 
4
 * Copyright (C) 2001 Ximian, Inc.
 
5
 *
 
6
 * Written by Bradford Hovinen <hovinen@ximian.com>
 
7
 *
 
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)
 
11
 * any later version.
 
12
 *
 
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.
 
17
 *
 
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
 
21
 * 02111-1307, USA.
 
22
 */
 
23
 
 
24
#ifndef __CAPPLET_UTIL_H
 
25
#define __CAPPLET_UTIL_H
 
26
 
 
27
#include <gnome.h>
 
28
#include <gconf/gconf.h>
 
29
#include <gconf/gconf-changeset.h>
 
30
 
 
31
/* Macros to make certain repetitive tasks a bit easier */
 
32
 
 
33
/* Print a debugging message */
 
34
 
 
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)
 
43
#else
 
44
#  define DEBUG_MSG(str, args...)
 
45
#endif
 
46
 
 
47
/* Retrieve a widget from the Glade object */
 
48
 
 
49
#define WID(s) glade_xml_get_widget (dialog, s)
 
50
 
 
51
/* Copy a setting from the legacy gnome-config settings to the ConfigDatabase */
 
52
 
 
53
#define COPY_FROM_LEGACY(type, key, legacy_key)                                 \
 
54
        val_##type = gnome_config_get_##type##_with_default (legacy_key, &def); \
 
55
                                                                                \
 
56
        if (!def)                                                               \
 
57
                gconf_client_set_##type (client, key, val_##type, NULL);
 
58
 
 
59
/* Callback to apply the settings in the given database */
 
60
typedef void (*ApplySettingsFn) (void);
 
61
 
 
62
/* Callback to set up the dialog proper */
 
63
typedef GtkWidget *(*CreateDialogFn) (void);
 
64
 
 
65
/* Callback to set up property editors for the dialog */
 
66
typedef void (*SetupPropertyEditorsFn) (GtkWidget *dialog, GConfChangeSet *changeset);
 
67
 
 
68
/* Callback to retrieve legacy settings and store them in the new configuration
 
69
 * database */
 
70
typedef void (*GetLegacySettingsFn) (void);
 
71
 
 
72
/* Set up the session management so that this capplet will apply its
 
73
 * settings on every startup
 
74
 */
 
75
 
 
76
void setup_session_mgmt (const gchar *binary_name);
 
77
 
 
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()
 
81
 *
 
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:
 
85
 *
 
86
 *   - The factory IID is Bonobo_Control_Capplet_foo_properties_Factory
 
87
 *   - The default configuration moniker is archiver:foo-properties
 
88
 *
 
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.
 
92
 */
 
93
 
 
94
void capplet_init (int                      argc,
 
95
                   gchar                  **argv,
 
96
                   ApplySettingsFn          apply_fn,
 
97
                   CreateDialogFn           create_dialog_fn,
 
98
                   SetupPropertyEditorsFn   setup_property_editors_fn,
 
99
                   GetLegacySettingsFn      get_legacy_settings_fn);
 
100
 
 
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);
 
104
 
 
105
#endif /* __CAPPLET_UTIL_H */