Add button_press_event() callback into LXPanelPluginInit struct.
[lxde/lxpanel.git] / src / plugin.h
1 /*
2 * Copyright (c) 2014 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__ 1
21
22 #include <libfm/fm.h>
23
24 #include "panel.h"
25 #include "conf.h"
26
27 G_BEGIN_DECLS
28
29 /* New plugins style which uses FmModule loader, our module type is "lxpanel_gtk" */
30
31 #define FM_MODULE_lxpanel_gtk_VERSION 1 /* version of this API */
32
33 /**
34 * @init: (allow-none): callback on lxpanel start
35 * @finalize: (allow-none): callback on lxpanel exit
36 * @name: name to represent plugin in lists
37 * @description: tooltip on the plugin in lists
38 * @new_instance: callback to create new plugin instance in panel
39 * @config: (allow-none): callback to show configuration dialog
40 * @reconfigure: (allow-none): callback to apply panel configuration change
41 * @button_press_event: (allow-none): callback on "button-press-event" signal
42 */
43 typedef struct {
44 /*< public >*/
45 void (*init)(void); /* optional startup */
46 void (*finalize)(void); /* optional finalize */
47 char *name; /* name to represent in lists */
48 char *description; /* tooltip text */
49 GtkWidget *(*new_instance)(Panel *panel, config_setting_t *settings);
50 void (*config)(Panel *panel, GtkWidget *instance, GtkWindow *parent);
51 void (*reconfigure)(Panel *panel, GtkWidget *instance);
52 gboolean (*button_press_event)(GtkWidget *widget, GdkEventButton *event, Panel *panel);
53 int one_per_system : 1; /* True to disable more than one instance */
54 int expand_available : 1; /* True if "stretch" option is available */
55 int expand_default : 1; /* True if "stretch" option is default */
56 /*< private >*/
57 gpointer _reserved1;
58 gpointer _reserved2;
59 } LXPanelPluginInit; /* constant data */
60
61 extern LXPanelPluginInit fm_module_init_lxpanel_gtk;
62
63 extern GQuark lxpanel_plugin_qdata; /* access to plugin private data */
64 #define lxpanel_plugin_get_data(_i) g_object_get_qdata(G_OBJECT(_i),lxpanel_plugin_qdata)
65 #define lxpanel_plugin_set_data(_i,_data,_destructor) g_object_set_qdata_full(G_OBJECT(_i),lxpanel_plugin_qdata,_data,_destructor)
66
67 /* register new plugin type - can be called from plugins init() too */
68 extern gboolean lxpanel_register_plugin_type(const char *name, LXPanelPluginInit *init);
69
70 /* few helper functions */
71 extern GtkMenu* lxpanel_get_plugin_menu(Panel* panel, GtkWidget* plugin, gboolean use_sub_menu);
72 extern gboolean lxpanel_plugin_button_press_event(GtkWidget *plugin, GdkEventButton *event, Panel *panel);
73 /* Handler for "button_press_event" signal with Plugin as parameter */
74 extern void lxpanel_plugin_adjust_popup_position(GtkWidget * popup, GtkWidget * plugin);
75 /* Helper to move popup windows away from the panel */
76 extern void lxpanel_plugin_popup_set_position_helper(Panel * p, GtkWidget * near, GtkWidget * popup, GtkRequisition * popup_req, gint * px, gint * py);
77 /* Helper for position-calculation callback for popup menus */
78 extern void plugin_widget_set_background(GtkWidget * plugin, Panel * p);
79 /* Recursively set the background of all widgets on a panel background configuration change */
80
81 G_END_DECLS
82
83 #endif /* __PLUGIN_H__ */