Adding upstream version 0.4.1+svn20090524.
[debian/lxpanel.git] / include / lxpanel / plugin.h
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 LXPANEL_PLUGIN_H
20 #define LXPANEL_PLUGIN_H
21
22 #include <X11/Xlib.h>
23 #include <gtk/gtk.h>
24 #include <stdio.h>
25
26 typedef FbEv;
27 typedef FbBg;
28 typedef pair;
29
30 extern FbEv *fbev;
31 extern pair bool_pair[];
32
33 /* Panel */
34 enum { ALLIGN_NONE, ALLIGN_LEFT, ALLIGN_CENTER, ALLIGN_RIGHT };
35 enum { EDGE_NONE, EDGE_LEFT, EDGE_RIGHT, EDGE_TOP, EDGE_BOTTOM };
36 enum { WIDTH_NONE, WIDTH_REQUEST, WIDTH_PIXEL, WIDTH_PERCENT };
37 enum { HEIGHT_NONE, HEIGHT_PIXEL, HEIGHT_REQUEST };
38 enum {
39 ORIENT_NONE = -1,
40 ORIENT_VERT = GTK_ORIENTATION_VERTICAL,
41 ORIENT_HORIZ = GTK_ORIENTATION_HORIZONTAL
42 };
43 enum { POS_NONE, POS_START, POS_END };
44
45 typedef struct _Panel Panel;
46 struct _Panel{
47 char* name;
48 GtkWidget *topgwin;
49 Window topxwin;
50 GtkStyle *defstyle;
51 GtkWidget *box;
52
53 GtkRequisition requisition;
54 GtkWidget *(*my_box_new) (gboolean, gint);
55 GtkWidget *(*my_separator_new) ();
56
57 FbBg *bg;
58 int alpha;
59 guint32 tintcolor;
60 guint32 fontcolor;
61 GdkColor gtintcolor;
62 GdkColor gfontcolor;
63
64 int ax, ay, aw, ah;
65 int cx, cy, cw, ch;
66 int allign, edge, margin;
67 int orientation;
68 int widthtype, width;
69 int heighttype, height;
70
71 guint config_changed : 1;
72 guint self_destroy : 1;
73 guint setdocktype : 1;
74 guint setstrut : 1;
75 guint round_corners : 1;
76 guint usefontcolor : 1;
77 guint transparent : 1;
78 guint background : 1;
79 guint spacing;
80
81 int desknum;
82 int curdesk;
83 guint32 *workarea;
84 int wa_len;
85
86 char* background_file;
87
88 int plug_num;
89 GList *plugins;
90
91 GSList* system_menus;
92
93 GtkWidget* pref_dialog;
94 };
95
96 /* Plugin */
97 struct _Plugin;
98 typedef struct {
99 char *fname;
100 int count;
101 GModule *gmodule;
102
103 int dynamic : 1;
104 int invisible : 1;
105 char *type;
106 char *name;
107 char *version;
108 char *description;
109
110 int (*constructor)(struct _Plugin *this, char **fp);
111 void (*destructor)(struct _Plugin *this);
112 void (*config)(struct _Plugin *this, GtkWindow* parent);
113 void (*save)(struct _Plugin *this, FILE* fp);
114 void (*orientation)(struct _Plugin *this);
115 } PluginClass;
116
117 typedef struct _Plugin{
118 PluginClass *class;
119 Panel *panel;
120 GtkWidget *pwid;
121 int expand;
122 int padding;
123 int border;
124 gpointer priv;
125 } Plugin;
126
127 /* misc */
128 enum {
129 CONF_TYPE_STR,
130 CONF_TYPE_INT,
131 CONF_TYPE_BOOL,
132 CONF_TYPE_FILE,
133 CONF_TYPE_FILE_ENTRY
134 };
135
136 enum { LINE_NONE, LINE_BLOCK_START, LINE_BLOCK_END, LINE_VAR };
137
138 typedef struct {
139 int num, len, type;
140 gchar str[256];
141 gchar *t[3];
142 } line;
143
144 /* Config Stuffs */
145 int str2num(pair *p, gchar *str, int defval);
146 gchar *num2str(pair *p, int num, gchar *defval);
147
148 extern int lxpanel_get_line(char **fp, line *s);
149 extern int lxpanel_put_line(FILE* fp, const char* format, ...);
150 #define lxpanel_put_str(fp, name, val) (G_UNLIKELY( !(val) || !*(val) )) ? 0 : lxpanel_put_line(fp, "%s=%s", name, val)
151 #define lxpanel_put_bool(fp, name, val) lxpanel_put_line(fp, "%s=%c", name, (val) ? '1' : '0')
152 #define lxpanel_put_int(fp, name, val) lxpanel_put_line(fp, "%s=%d", name, val)
153
154
155 /* For debuging */
156 #define ERR(fmt, args...) fprintf(stderr, fmt, ## args)
157 #define DBG2(fmt, args...) fprintf(stderr, "%s:%s:%-5d: " fmt, __FILE__, __FUNCTION__, __LINE__, ## args)
158 #define ENTER2 do { fprintf(stderr, "%s:%s:%-5d: ENTER\n", __FILE__,__FUNCTION__, __LINE__); } while(0)
159 #define RET2(args...) do { fprintf(stderr, "%s:%s:%-5d: RETURN\n", __FILE__,__FUNCTION__, __LINE__);\
160 return args; } while(0)
161
162 enum { LOG_NONE, LOG_ERR, LOG_WARN, LOG_INFO, LOG_ALL };
163 #ifdef DEBUG
164
165 #define ENTER do { fprintf(stderr, "%s:%s:%-5d: ENTER\n", __FILE__,__FUNCTION__, __LINE__); } while(0)
166 #define RET(args...) do { fprintf(stderr, "%s:%s:%-5d: RETURN\n", __FILE__, __FUNCTION__, __LINE__);\
167 return args; } while(0)
168 #define DBG(fmt, args...) fprintf(stderr, "%s:%s:%-5d: " fmt, __FILE__,__FUNCTION__, __LINE__, ## args)
169 #define LOG(level, fmt, args...) fprintf(stderr, fmt, ## args)
170
171 #else
172
173 extern int log_level;
174 #define ENTER do { } while(0)
175 #define RET(args...) return args
176 #define DBG(fmt, args...) do { } while(0)
177 #define LOG(level, fmt, args...) do { if (level <= log_level) fprintf(stderr, fmt, ## args); } while(0)
178
179 #endif
180
181 /* X11 */
182 extern Atom a_UTF8_STRING;
183 extern Atom a_XROOTPMAP_ID;
184
185 extern Atom a_WM_STATE;
186 extern Atom a_WM_CLASS;
187 extern Atom a_WM_DELETE_WINDOW;
188 extern Atom a_WM_PROTOCOLS;
189 extern Atom a_NET_WORKAREA;
190 extern Atom a_NET_CLIENT_LIST;
191 extern Atom a_NET_CLIENT_LIST_STACKING;
192 extern Atom a_NET_NUMBER_OF_DESKTOPS;
193 extern Atom a_NET_CURRENT_DESKTOP;
194 extern Atom a_NET_DESKTOP_VIEWPORT;
195 extern Atom a_NET_DESKTOP_NAMES;
196 extern Atom a_NET_ACTIVE_WINDOW;
197 extern Atom a_NET_CLOSE_WINDOW;
198 extern Atom a_NET_SUPPORTED;
199 extern Atom a_NET_WM_STATE;
200 extern Atom a_NET_WM_STATE_SKIP_TASKBAR;
201 extern Atom a_NET_WM_STATE_SKIP_PAGER;
202 extern Atom a_NET_WM_STATE_STICKY;
203 extern Atom a_NET_WM_STATE_HIDDEN;
204 extern Atom a_NET_WM_STATE_SHADED;
205
206 #define a_NET_WM_STATE_REMOVE 0 /* remove/unset property */
207 #define a_NET_WM_STATE_ADD 1 /* add/set property */
208 #define a_NET_WM_STATE_TOGGLE 2 /* toggle property */
209
210 extern Atom a_NET_WM_WINDOW_TYPE;
211 extern Atom a_NET_WM_WINDOW_TYPE_DESKTOP;
212 extern Atom a_NET_WM_WINDOW_TYPE_DOCK;
213 extern Atom a_NET_WM_WINDOW_TYPE_TOOLBAR;
214 extern Atom a_NET_WM_WINDOW_TYPE_MENU;
215 extern Atom a_NET_WM_WINDOW_TYPE_UTILITY;
216 extern Atom a_NET_WM_WINDOW_TYPE_SPLASH;
217 extern Atom a_NET_WM_WINDOW_TYPE_DIALOG;
218 extern Atom a_NET_WM_WINDOW_TYPE_NORMAL;
219
220 extern Atom a_NET_WM_DESKTOP;
221 extern Atom a_NET_WM_NAME;
222 extern Atom a_NET_WM_VISIBLE_NAME;
223 extern Atom a_NET_WM_STRUT;
224 extern Atom a_NET_WM_STRUT_PARTIAL;
225 extern Atom a_NET_WM_ICON;
226 extern Atom a_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR;
227 extern Atom a_LXPANEL_CMD; /* for private client message */
228
229 /* glib-mem */
230 #include <glib.h>
231
232 #if ! GLIB_CHECK_VERSION(2, 10, 0)
233 /* older versions of glib don't provde g_slice API */
234 #define g_slice_alloc(size) g_malloc(size)
235 #define g_slice_alloc0(size) g_malloc0(size)
236 #define g_slice_new(type) g_new(type, 1)
237 #define g_slice_new0(type) g_new0(type, 1)
238 #define g_slice_free(type, mem) g_free(mem)
239 #define g_slice_free1(size, mem) g_free(mem)
240 #endif
241
242 #endif