Adding upstream version 0.5.12.
[debian/lxpanel.git] / src / plugin.h
CommitLineData
6cc5e1a6
DB
1/**
2 * Copyright (c) 2006 LxDE Developers, see the file AUTHORS for details.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#ifndef PLUGIN_H
20#define PLUGIN_H
21
22#include <gmodule.h>
23
24#include <gtk/gtk.h>
25#include <gdk/gdk.h>
26#include <stdio.h>
27#include "panel.h"
28
9a3614f5
DB
29struct _Plugin;
30
2ba86315
DB
31/* Support for external plugin versioning.
32 * Plugins must invoke PLUGINCLASS_VERSIONING when they instantiate PluginClass. */
33#define PLUGINCLASS_VERSION 1
34#define PLUGINCLASS_VERSIONING \
35 structure_size : sizeof(PluginClass), \
36 structure_version : PLUGINCLASS_VERSION
37
38/* Representative of an available plugin. */
6cc5e1a6 39typedef struct {
6cc5e1a6 40
2ba86315
DB
41 /* Keep these first. Do not make unnecessary changes in structure layout. */
42 unsigned short structure_size; /* Structure size, for versioning support */
43 unsigned short structure_version; /* Structure version, for versioning support */
44
45 char * fname; /* Plugin file pathname */
46 int count; /* Reference count */
47 GModule * gmodule; /* Associated GModule structure */
48
49 int dynamic : 1; /* True if dynamically loaded */
50 int unused_invisible : 1; /* Unused; reserved bit */
51 int not_unloadable : 1; /* Not unloadable due to GModule restriction */
52 int one_per_system : 1; /* Special: only one possible per system, such as system tray */
53 int one_per_system_instantiated : 1; /* True if one instance exists */
54 int expand_available : 1; /* True if "stretch" option is available */
55 int expand_default : 1; /* True if "stretch" option is default */
56
57 /* These fields point within the plugin image. */
58 char * type; /* Internal name of plugin, to match external filename */
59 char * name; /* Display name of plugin for selection UI */
60 char * version; /* Version of plugin */
61 char * description; /* Brief textual description of plugin for selection UI */
62
63 int (*constructor)(struct _Plugin * plugin, char ** fp); /* Create an instance of the plugin */
64 void (*destructor)(struct _Plugin * plugin); /* Destroy an instance of the plugin */
65 void (*config)(struct _Plugin * plugin, GtkWindow * parent); /* Request the plugin to display its configuration dialog */
66 void (*save)(struct _Plugin * plugin, FILE * fp); /* Request the plugin to save its configuration to a file */
67 void (*panel_configuration_changed)(struct _Plugin * plugin); /* Request the plugin to do a full redraw after a panel configuration change */
6cc5e1a6
DB
68} PluginClass;
69
2ba86315
DB
70/* Representative of a loaded and active plugin attached to a panel. */
71typedef struct _Plugin {
72 PluginClass * class; /* Back pointer to PluginClass */
73 Panel * panel; /* Back pointer to Panel */
74 GtkWidget * pwid; /* Top level widget; plugin allocates, but plugin mechanism, not plugin itself, destroys this */
75 int expand; /* Expand ("stretch") setting for container */
76 int padding; /* Padding setting for container */
77 int border; /* Border setting for container */
78 gpointer priv; /* Private context for plugin; plugin frees this in its destructor */
6cc5e1a6
DB
79} Plugin;
80
2ba86315
DB
81extern Plugin * plugin_load(char * type); /* Create an instance of a plugin, loading it if necessary */
82extern int plugin_start(Plugin * this, char ** fp); /* Configure and start a plugin by calling its constructor */
83extern void plugin_unload(Plugin * pl); /* Delete an instance of a plugin if initialization fails */
84extern void plugin_delete(Plugin * pl); /* Delete an instance of a plugin */
85extern GList * plugin_get_available_classes(void); /* Get a list of all plugin classes; free with plugin_class_list_free */
86extern void plugin_class_list_free(GList * list); /* Free the list allocated by plugin_get_available_classes */
87extern void plugin_widget_set_background(GtkWidget * w, Panel * p);
88 /* Recursively set the background of all widgets on a panel background configuration change */
89extern gboolean plugin_button_press_event(GtkWidget *widget, GdkEventButton *event, Plugin *plugin);
90 /* Handler for "button_press_event" signal with Plugin as parameter */
91extern void plugin_popup_set_position_helper(Plugin * p, GtkWidget * near, GtkWidget * popup, GtkRequisition * popup_req, gint * px, gint * py);
92 /* Helper for position-calculation callback for popup menus */
32a67dc7
DB
93extern void plugin_adjust_popup_position(GtkWidget * popup, Plugin * plugin);
94 /* Helper to move popup windows away from the panel */
6cc5e1a6
DB
95
96/* FIXME: optional definitions */
97#define STATIC_SEPARATOR
6cc5e1a6
DB
98#define STATIC_LAUNCHBAR
99#define STATIC_DCLOCK
100#define STATIC_WINCMD
101#define STATIC_DIRMENU
102#define STATIC_TASKBAR
103#define STATIC_PAGER
104#define STATIC_TRAY
105#define STATIC_MENU
106#define STATIC_SPACE
107#define STATIC_ICONS
108
6cc5e1a6 109#endif