~ubuntu-branches/debian/experimental/xfce4-panel/experimental

« back to all changes in this revision

Viewing changes to libxfce4panel/xfce-panel-plugin.h

  • Committer: Bazaar Package Importer
  • Author(s): Yves-Alexis Perez
  • Date: 2008-05-19 08:08:22 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20080519080822-c8ptdv1s8o9r4ou0
Tags: 4.4.2-6
* switch to triggers:
  - debian/postinst: remove xfce-mcs-manager refresh.
  - debian/prerm dropped.
  - debian/control: conflicts against non-triggers-enable xfce4-mcs-manager.
* debian/control: remove useless Conflicts/Replaces against Sarge stuff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vim: set expandtab ts=8 sw=4: */
 
2
 
 
3
/*  $Id: xfce-panel-plugin.h 25735 2007-05-20 17:48:28Z jasper $
 
4
 *
 
5
 *  Copyright © 2005 Jasper Huijsmans <jasper@xfce.org>
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU Library General Public License as published 
 
9
 *  by the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU Library General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU Library General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 */
 
21
 
 
22
#ifndef _XFCE_PANEL_PLUGIN_H
 
23
#define _XFCE_PANEL_PLUGIN_H
 
24
 
 
25
#include <stdlib.h>
 
26
#include <libxfce4panel/xfce-panel-enums.h>
 
27
#include <libxfce4panel/xfce-panel-macros.h>
 
28
#include <libxfce4panel/xfce-panel-plugin-iface.h>
 
29
#include <libxfce4panel/xfce-panel-internal-plugin.h> 
 
30
#include <libxfce4panel/xfce-panel-external-plugin.h>
 
31
 
 
32
/**
 
33
 * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL
 
34
 * @construct : name of a function that can be cast to an #XfcePanelPluginFunc
 
35
 *
 
36
 * Registers and initializes the plugin. This is the only thing that is
 
37
 * required to create a panel plugin.
 
38
 *
 
39
 * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link>
 
40
 **/
 
41
#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL(construct)  \
 
42
                XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL(construct,NULL,NULL)
 
43
 
 
44
/**
 
45
 * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK
 
46
 * @construct : name of a function that can be cast to an
 
47
 *              #XfcePanelPluginFunc
 
48
 * @check     : name of a function that can be cast to an
 
49
 *              #XfcePanelPluginCheck
 
50
 *
 
51
 * Registers and initializes the plugin. This is the only thing that is
 
52
 * required to create a panel plugin. The @check functions is run before
 
53
 * creating the plugin, and should return FALSE if plugin creation is not
 
54
 * possible.
 
55
 *
 
56
 * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link>
 
57
 **/
 
58
#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_WITH_CHECK(construct,check) \
 
59
                XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL(construct,NULL,check)
 
60
 
 
61
/**
 
62
 * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL
 
63
 * @construct : name of a function that can be cast to #XfcePanelPluginFunc
 
64
 * @init      : name of a function that can be case to #XfcePanelPluginPreInit
 
65
 *              or NULL
 
66
 * @check     : name of a function that can be cast to #XfcePanelPluginCheck
 
67
 *              or NULL
 
68
 *
 
69
 * Registers and initializes the plugin. This is the only thing that is
 
70
 * required to create a panel plugin.
 
71
 *
 
72
 * The @init argument should be a function that takes two parameters:
 
73
 *
 
74
 *   gboolean init( int argc, char **argv );
 
75
 *
 
76
 * The @check functions is run aftern gtk_init() and before creating the 
 
77
 * plugin; it takes one argument and should return FALSE if plugin creation 
 
78
 * is not possible:
 
79
 *
 
80
 *   gboolean check( GdkScreen *screen );
 
81
 *
 
82
 * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link>
 
83
 **/
 
84
#define XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL_FULL(construct,init,check)          \
 
85
    gint                                                                        \
 
86
    main (gint argc, gchar **argv)                                              \
 
87
    {                                                                           \
 
88
        GtkWidget              *plugin;                                         \
 
89
        XfcePanelPluginFunc     create  = (XfcePanelPluginFunc)construct;       \
 
90
        XfcePanelPluginPreInit  preinit = (XfcePanelPluginPreInit)init;         \
 
91
        XfcePanelPluginCheck    test    = (XfcePanelPluginCheck)check;          \
 
92
                                                                                \
 
93
        if ( preinit )                                                          \
 
94
        {                                                                       \
 
95
            if (G_UNLIKELY (preinit(argc,argv) == FALSE))                               \
 
96
                return 3;                                                       \
 
97
        }                                                                       \
 
98
                                                                                \
 
99
        gtk_init (&argc, &argv);                                                \
 
100
                                                                                \
 
101
        if ( test )                                                             \
 
102
        {                                                                       \
 
103
            if (G_UNLIKELY (test(gdk_screen_get_default()) == FALSE))           \
 
104
                return 2;                                                       \
 
105
        }                                                                       \
 
106
                                                                                \
 
107
        plugin = xfce_external_panel_plugin_new (argc, argv, create);           \
 
108
                                                                                \
 
109
        if (G_UNLIKELY (plugin == NULL))                                        \
 
110
            return 1;                                                           \
 
111
                                                                                \
 
112
        g_signal_connect_after (G_OBJECT (plugin), "destroy",                   \
 
113
                                G_CALLBACK (gtk_main_quit), NULL);              \
 
114
                                                                                \
 
115
        gtk_widget_show (plugin);                                               \
 
116
        gtk_main ();                                                            \
 
117
                                                                                \
 
118
        return 0;                                                               \
 
119
    }
 
120
 
 
121
/**
 
122
 * XFCE_PANEL_PLUGIN_REGISTER_INTERNAL
 
123
 * @construct : name of a function that can be cast to an #XfcePanelPluginFunc
 
124
 *
 
125
 * Registers and initializes the plugin. This is the only thing that is 
 
126
 * required to create a panel plugin.
 
127
 *
 
128
 * This macro is for plugins implemented as a loadable module. Generally it is
 
129
 * preferred to create an external plugin, for which you have to use
 
130
 * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL() .
 
131
 *
 
132
 * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link>
 
133
 **/
 
134
#define XFCE_PANEL_PLUGIN_REGISTER_INTERNAL(construct) \
 
135
    XfcePanelPluginFunc \
 
136
    xfce_panel_plugin_get_construct (void) \
 
137
    { \
 
138
        return (XfcePanelPluginFunc)construct; \
 
139
    }
 
140
 
 
141
/**
 
142
 * XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK
 
143
 * @construct : name of a function that can be cast to an #XfcePanelPluginFunc
 
144
 * @check     : name of a function that can be cast to an
 
145
 *              #XfcePanelPluginCheck
 
146
 *
 
147
 * Registers and initializes the plugin. This is the only thing that is 
 
148
 * required to create a panel plugin. The @check function is run before
 
149
 * creating the plugin, and should return FALSE if plugin creation is not
 
150
 * possible.
 
151
 *
 
152
 * This macro is for plugins implemented as a loadable module. Generally it is
 
153
 * preferred to create an external plugin, for which you have to use
 
154
 * XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL() .
 
155
 *
 
156
 * See also: <link linkend="XfcePanelPlugin">Panel Plugin interface</link>
 
157
 **/
 
158
#define XFCE_PANEL_PLUGIN_REGISTER_INTERNAL_WITH_CHECK(construct,check) \
 
159
    XfcePanelPluginFunc \
 
160
    xfce_panel_plugin_get_construct (void) \
 
161
    { \
 
162
        return (XfcePanelPluginFunc)construct; \
 
163
    } \
 
164
    XfcePanelPluginCheck \
 
165
    xfce_panel_plugin_get_check (void) \
 
166
    { \
 
167
        return (XfcePanelPluginCheck)check; \
 
168
    }
 
169
 
 
170
#endif /* _XFCE_PANEL_PLUGIN_H */