Merging upstream version 0.5.9.
[debian/lxpanel.git] / src / panel.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 PANEL_H
20 #define PANEL_H
21
22 #include <X11/Xlib.h>
23 #include <gtk/gtk.h>
24 #include <gdk/gdk.h>
25
26 #include "config.h"
27
28 #include "bg.h"
29 #include "ev.h"
30
31 enum { ALLIGN_NONE, ALLIGN_LEFT, ALLIGN_CENTER, ALLIGN_RIGHT };
32 enum { EDGE_NONE, EDGE_LEFT, EDGE_RIGHT, EDGE_TOP, EDGE_BOTTOM };
33 enum { WIDTH_NONE, WIDTH_REQUEST, WIDTH_PIXEL, WIDTH_PERCENT };
34 enum { HEIGHT_NONE, HEIGHT_PIXEL, HEIGHT_REQUEST };
35 enum {
36 ORIENT_NONE = -1,
37 ORIENT_VERT = GTK_ORIENTATION_VERTICAL,
38 ORIENT_HORIZ = GTK_ORIENTATION_HORIZONTAL
39 };
40 enum { POS_NONE, POS_START, POS_END };
41
42 #define PANEL_ICON_SIZE 24 /* Default size of panel icons */
43 #define PANEL_HEIGHT_DEFAULT 26 /* Default height of horizontal panel */
44 #define PANEL_WIDTH_DEFAULT 150 /* Default "height" of vertical panel */
45 #define PANEL_HEIGHT_MAX 200 /* Maximum height of panel */
46 #define PANEL_HEIGHT_MIN 16 /* Minimum height of panel */
47 #define PANEL_ICON_HIGHLIGHT 0x202020 /* Constant to pass to icon loader */
48
49 /* to check if we are in LXDE */
50 extern gboolean is_in_lxde;
51
52 /* Context of a panel on a given edge. */
53 typedef struct _Panel {
54 char* name;
55 GtkWidget * topgwin; /* Main panel window */
56 Window topxwin; /* Main panel's X window */
57 GdkDisplay * display; /* Main panel's GdkDisplay */
58 GtkStyle * defstyle;
59
60 GtkWidget * box; /* Top level widget */
61
62 GtkRequisition requisition;
63 GtkWidget *(*my_box_new) (gboolean, gint);
64 GtkWidget *(*my_separator_new) ();
65
66 FbBg *bg;
67 int alpha;
68 guint32 tintcolor;
69 guint32 fontcolor;
70 GdkColor gtintcolor;
71 GdkColor gfontcolor;
72
73 int ax, ay, aw, ah; /* prefferd allocation of a panel */
74 int cx, cy, cw, ch; /* current allocation (as reported by configure event) allocation */
75 int allign, edge, margin;
76 int orientation;
77 int widthtype, width;
78 int heighttype, height;
79 gulong strut_size; /* Values for WM_STRUT_PARTIAL */
80 gulong strut_lower;
81 gulong strut_upper;
82 int strut_edge;
83
84 guint config_changed : 1;
85 guint self_destroy : 1;
86 guint setdocktype : 1;
87 guint setstrut : 1;
88 guint round_corners : 1;
89 guint usefontcolor : 1;
90 guint usefontsize : 1;
91 guint fontsize;
92 guint transparent : 1;
93 guint background : 1;
94 guint spacing;
95
96 guint autohide : 1;
97 guint visible : 1;
98 int height_when_hidden;
99 guint hide_timeout;
100 int icon_size; /* Icon size */
101
102 int desknum;
103 int curdesk;
104 guint32 *workarea;
105 int wa_len;
106
107 char* background_file;
108
109 GList * plugins; /* List of all plugins */
110 GSList * system_menus; /* List of plugins having menus */
111
112 GtkWidget* plugin_pref_dialog; /* Plugin preference dialog */
113 GtkWidget* pref_dialog; /* preference dialog */
114 GtkWidget* margin_control; /* Margin control in preference dialog */
115 GtkWidget* height_label; /* Label of height control */
116 GtkWidget* width_label; /* Label of width control */
117 GtkWidget* alignment_left_label; /* Label of alignment: left control */
118 GtkWidget* alignment_right_label; /* Label of alignment: right control */
119 GtkWidget* height_control; /* Height control in preference dialog */
120 GtkWidget* width_control; /* Width control in preference dialog */
121 } Panel;
122
123 /* Decoded value of WM_STATE property. */
124 typedef struct {
125 unsigned int modal : 1;
126 unsigned int sticky : 1;
127 unsigned int maximized_vert : 1;
128 unsigned int maximized_horz : 1;
129 unsigned int shaded : 1;
130 unsigned int skip_taskbar : 1;
131 unsigned int skip_pager : 1;
132 unsigned int hidden : 1;
133 unsigned int fullscreen : 1;
134 unsigned int above : 1;
135 unsigned int below : 1;
136 } NetWMState;
137
138 /* Decoded value of _NET_WM_WINDOW_TYPE property. */
139 typedef struct {
140 unsigned int desktop : 1;
141 unsigned int dock : 1;
142 unsigned int toolbar : 1;
143 unsigned int menu : 1;
144 unsigned int utility : 1;
145 unsigned int splash : 1;
146 unsigned int dialog : 1;
147 unsigned int normal : 1;
148 } NetWMWindowType;
149
150 typedef struct {
151 char *name;
152 char *disp_name;
153 void (*cmd)(void);
154 } Command;
155
156 extern Command commands[];
157
158 extern gchar *cprofile;
159
160 extern Atom a_UTF8_STRING;
161 extern Atom a_XROOTPMAP_ID;
162
163 extern Atom a_WM_STATE;
164 extern Atom a_WM_CLASS;
165 extern Atom a_WM_DELETE_WINDOW;
166 extern Atom a_WM_PROTOCOLS;
167 extern Atom a_NET_WORKAREA;
168 extern Atom a_NET_CLIENT_LIST;
169 extern Atom a_NET_CLIENT_LIST_STACKING;
170 extern Atom a_NET_NUMBER_OF_DESKTOPS;
171 extern Atom a_NET_CURRENT_DESKTOP;
172 extern Atom a_NET_DESKTOP_VIEWPORT;
173 extern Atom a_NET_DESKTOP_NAMES;
174 extern Atom a_NET_ACTIVE_WINDOW;
175 extern Atom a_NET_CLOSE_WINDOW;
176 extern Atom a_NET_SHOWING_DESKTOP;
177 extern Atom a_NET_SUPPORTED;
178 extern Atom a_NET_WM_STATE;
179 extern Atom a_NET_WM_STATE_SKIP_TASKBAR;
180 extern Atom a_NET_WM_STATE_SKIP_PAGER;
181 extern Atom a_NET_WM_STATE_STICKY;
182 extern Atom a_NET_WM_STATE_HIDDEN;
183 extern Atom a_NET_WM_STATE_SHADED;
184
185 #define a_NET_WM_STATE_REMOVE 0 /* remove/unset property */
186 #define a_NET_WM_STATE_ADD 1 /* add/set property */
187 #define a_NET_WM_STATE_TOGGLE 2 /* toggle property */
188
189 extern Atom a_NET_WM_WINDOW_TYPE;
190 extern Atom a_NET_WM_WINDOW_TYPE_DESKTOP;
191 extern Atom a_NET_WM_WINDOW_TYPE_DOCK;
192 extern Atom a_NET_WM_WINDOW_TYPE_TOOLBAR;
193 extern Atom a_NET_WM_WINDOW_TYPE_MENU;
194 extern Atom a_NET_WM_WINDOW_TYPE_UTILITY;
195 extern Atom a_NET_WM_WINDOW_TYPE_SPLASH;
196 extern Atom a_NET_WM_WINDOW_TYPE_DIALOG;
197 extern Atom a_NET_WM_WINDOW_TYPE_NORMAL;
198
199 extern Atom a_NET_WM_DESKTOP;
200 extern Atom a_NET_WM_NAME;
201 extern Atom a_NET_WM_VISIBLE_NAME;
202 extern Atom a_NET_WM_STRUT;
203 extern Atom a_NET_WM_STRUT_PARTIAL;
204 extern Atom a_NET_WM_ICON;
205 extern Atom a_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR;
206
207 extern Atom a_NET_SYSTEM_TRAY_OPCODE;
208 extern Atom a_NET_SYSTEM_TRAY_MESSAGE_DATA;
209 extern Atom a_NET_SYSTEM_TRAY_ORIENTATION;
210 extern Atom a_MANAGER;
211
212 extern Atom a_LXPANEL_CMD; /* for private client message */
213
214 extern int verbose;
215
216 /* if current window manager is EWMH conforming. */
217 extern gboolean is_ewmh_supported;
218
219 extern FbEv *fbev;
220
221 #define FBPANEL_WIN(win) gdk_window_lookup(win)
222
223 extern void panel_apply_icon(GtkWindow *w);
224 extern void panel_destroy(Panel *p);
225 extern void panel_adjust_geometry_terminology(Panel *p);
226 extern void panel_determine_background_pixmap(Panel * p, GtkWidget * widget, GdkWindow * window);
227 extern void panel_draw_label_text(Panel * p, GtkWidget * label, char * text, gboolean bold, gboolean custom_color);
228 extern void panel_establish_autohide(Panel *p);
229 extern void panel_image_set_from_file(Panel * p, GtkWidget * image, const char * file);
230 extern gboolean panel_image_set_icon_theme(Panel * p, GtkWidget * image, const gchar * icon);
231 extern void panel_set_wm_strut(Panel *p);
232 extern void panel_set_dock_type(Panel *p);
233 extern void panel_set_panel_configuration_changed(Panel *p);
234 extern void panel_update_background( Panel* p );
235
236 extern int panel_handle_x_error(Display * d, XErrorEvent * ev);
237 extern int panel_handle_x_error_swallow_BadWindow_BadDrawable(Display * d, XErrorEvent * ev);
238
239 extern const char* lxpanel_get_file_manager();
240 extern const char* lxpanel_get_terminal();
241
242 #endif