2
* panel-applet.h: panel applet writing API.
4
* Copyright (C) 2001 Sun Microsystems, Inc.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this library; if not, write to the
18
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
22
* Mark McLoughlin <mark@skynet.ie>
25
#ifndef __PANEL_APPLET_H__
26
#define __PANEL_APPLET_H__
30
#include <bonobo/bonobo-control.h>
31
#include <bonobo/bonobo-main.h>
32
#include <bonobo/bonobo-ui-component.h>
33
#include <bonobo/bonobo-generic-factory.h>
35
#include <GNOME_Panel.h>
39
typedef GNOME_Vertigo_PanelOrient PanelAppletOrient;
41
#define PANEL_APPLET_ORIENT_UP GNOME_Vertigo_PANEL_ORIENT_UP
42
#define PANEL_APPLET_ORIENT_DOWN GNOME_Vertigo_PANEL_ORIENT_DOWN
43
#define PANEL_APPLET_ORIENT_LEFT GNOME_Vertigo_PANEL_ORIENT_LEFT
44
#define PANEL_APPLET_ORIENT_RIGHT GNOME_Vertigo_PANEL_ORIENT_RIGHT
47
#define PANEL_TYPE_APPLET (panel_applet_get_type ())
48
#define PANEL_APPLET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PANEL_TYPE_APPLET, PanelApplet))
49
#define PANEL_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PANEL_TYPE_APPLET, PanelAppletClass))
50
#define PANEL_IS_APPLET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PANEL_TYPE_APPLET))
51
#define PANEL_IS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PANEL_TYPE_APPLET))
52
#define PANEL_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PANEL_TYPE_APPLET, PanelAppletClass))
56
PANEL_COLOR_BACKGROUND,
57
PANEL_PIXMAP_BACKGROUND
58
} PanelAppletBackgroundType;
61
PANEL_APPLET_FLAGS_NONE = 0,
62
PANEL_APPLET_EXPAND_MAJOR = 1 << 0,
63
PANEL_APPLET_EXPAND_MINOR = 1 << 1,
64
PANEL_APPLET_HAS_HANDLE = 1 << 2
67
typedef struct _PanelApplet PanelApplet;
68
typedef struct _PanelAppletClass PanelAppletClass;
69
typedef struct _PanelAppletPrivate PanelAppletPrivate;
71
typedef gboolean (*PanelAppletFactoryCallback) (PanelApplet *applet,
76
GtkEventBox event_box;
78
PanelAppletPrivate *priv;
81
struct _PanelAppletClass {
82
GtkEventBoxClass event_box_class;
84
void (*change_orient) (PanelApplet *applet,
85
PanelAppletOrient orient);
87
void (*change_size) (PanelApplet *applet,
90
void (*change_background) (PanelApplet *applet,
91
PanelAppletBackgroundType type,
94
void (*move_focus_out_of_applet) (PanelApplet *frame,
95
GtkDirectionType direction);
98
GType panel_applet_get_type (void) G_GNUC_CONST;
100
GtkWidget *panel_applet_new (void);
102
PanelAppletOrient panel_applet_get_orient (PanelApplet *applet);
104
guint panel_applet_get_size (PanelApplet *applet);
106
PanelAppletBackgroundType
107
panel_applet_get_background (PanelApplet *applet,
112
void panel_applet_set_background_widget (PanelApplet *applet,
115
gchar *panel_applet_get_preferences_key (PanelApplet *applet);
117
void panel_applet_add_preferences (PanelApplet *applet,
118
const gchar *schema_dir,
121
PanelAppletFlags panel_applet_get_flags (PanelApplet *applet);
122
void panel_applet_set_flags (PanelApplet *applet,
123
PanelAppletFlags flags);
125
void panel_applet_set_size_hints (PanelApplet *applet,
126
const int *size_hints,
130
gboolean panel_applet_get_locked_down (PanelApplet *applet);
132
void panel_applet_request_focus (PanelApplet *applet,
135
BonoboControl *panel_applet_get_control (PanelApplet *applet);
136
BonoboUIComponent *panel_applet_get_popup_component (PanelApplet *applet);
138
void panel_applet_setup_menu (PanelApplet *applet,
140
const BonoboUIVerb *verb_list,
143
void panel_applet_setup_menu_from_file (PanelApplet *applet,
144
const gchar *opt_datadir,
146
const gchar *opt_app_name,
147
const BonoboUIVerb *verb_list,
151
int panel_applet_factory_main (const gchar *iid,
153
PanelAppletFactoryCallback callback,
156
int panel_applet_factory_main_closure (const gchar *iid,
160
Bonobo_Unknown panel_applet_shlib_factory (const char *iid,
162
PortableServer_POA poa,
164
PanelAppletFactoryCallback callback,
166
CORBA_Environment *ev);
168
Bonobo_Unknown panel_applet_shlib_factory_closure (const char *iid,
170
PortableServer_POA poa,
173
CORBA_Environment *ev);
176
* These macros are getting a bit unwieldy.
178
* Things to define for these:
179
* + required if Native Language Support is enabled (ENABLE_NLS):
180
* GETTEXT_PACKAGE and GNOMELOCALEDIR
183
#if !defined(ENABLE_NLS)
184
#define _PANEL_APPLET_SETUP_GETTEXT(call_textdomain) \
186
#else /* defined(ENABLE_NLS) */
188
#define _PANEL_APPLET_SETUP_GETTEXT(call_textdomain) \
190
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); \
191
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); \
192
if (call_textdomain) \
193
textdomain (GETTEXT_PACKAGE); \
195
#endif /* !defined(ENABLE_NLS) */
197
#define PANEL_APPLET_BONOBO_FACTORY(iid, type, name, version, callback, data) \
198
int main (int argc, char *argv []) \
200
GOptionContext *context; \
204
_PANEL_APPLET_SETUP_GETTEXT (TRUE); \
206
context = g_option_context_new (""); \
207
g_option_context_add_group (context, gtk_get_option_group (TRUE)); \
208
g_option_context_add_group (context, \
209
bonobo_activation_get_goption_group ()); \
212
if (!g_option_context_parse (context, &argc, &argv, &error)) { \
214
g_printerr ("Cannot parse arguments: %s.\n", \
216
g_error_free (error); \
218
g_printerr ("Cannot parse arguments.\n"); \
219
g_option_context_free (context); \
223
gtk_init (&argc, &argv); \
224
if (!bonobo_init (&argc, argv)) { \
225
g_printerr ("Cannot initialize bonobo.\n"); \
229
retval = panel_applet_factory_main (iid, type, callback, data); \
230
g_option_context_free (context); \
235
#define PANEL_APPLET_BONOBO_SHLIB_FACTORY(iid, type, descr, callback, data) \
236
static Bonobo_Unknown \
237
__panel_applet_shlib_factory (PortableServer_POA poa, \
238
const char *oafiid, \
240
CORBA_Environment *ev) \
242
_PANEL_APPLET_SETUP_GETTEXT (FALSE); \
243
return panel_applet_shlib_factory ((iid), (type), poa, impl_ptr, \
244
(callback), (data), ev); \
246
static BonoboActivationPluginObject plugin_list[] = { \
247
{ (iid), __panel_applet_shlib_factory }, \
250
const BonoboActivationPlugin Bonobo_Plugin_info = { plugin_list, (descr) };
254
#endif /* __PANEL_APPLET_H__ */