Adding upstream version 0.8.2.
[debian/lxpanel.git] / src / misc.h
CommitLineData
0688b017
AG
1/*
2 * Copyright (C) 2006-2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
3 * 2006-2008 Jim Huang <jserv.tw@gmail.com>
4 * 2008-2009 Fred Chien <fred@lxde.org>
5 * 2009 Marty Jack <martyj19@comcast.net>
6 * 2011-2013 Henry Gebhardt <hsggebhardt@gmail.com>
7 * 2014 Andriy Grytsenko <andrej@rep.kiev.ua>
8 *
9 * This file is a part of LXPanel project.
6cc5e1a6
DB
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
6b775dbb
AG
26#ifndef __MISC_H__
27#define __MISC_H__ 1
6cc5e1a6
DB
28
29#include <X11/Xatom.h>
30#include <gtk/gtk.h>
31#include <gdk/gdk.h>
32#include <gdk/gdkx.h>
33#include <stdio.h>
6b775dbb 34#include <libfm/fm.h>
6cc5e1a6
DB
35
36#include "panel.h"
6cc5e1a6 37
6b775dbb
AG
38G_BEGIN_DECLS
39
40extern Atom a_UTF8_STRING;
41extern Atom a_XROOTPMAP_ID;
42
43extern Atom a_WM_STATE;
44extern Atom a_WM_CLASS;
45extern Atom a_WM_DELETE_WINDOW;
46extern Atom a_WM_PROTOCOLS;
47extern Atom a_NET_WORKAREA;
48extern Atom a_NET_CLIENT_LIST;
49extern Atom a_NET_CLIENT_LIST_STACKING;
50extern Atom a_NET_NUMBER_OF_DESKTOPS;
51extern Atom a_NET_CURRENT_DESKTOP;
52extern Atom a_NET_DESKTOP_VIEWPORT;
53extern Atom a_NET_DESKTOP_NAMES;
54extern Atom a_NET_ACTIVE_WINDOW;
55extern Atom a_NET_CLOSE_WINDOW;
56extern Atom a_NET_SHOWING_DESKTOP;
57extern Atom a_NET_SUPPORTED;
58extern Atom a_NET_WM_STATE;
59extern Atom a_NET_WM_STATE_SKIP_TASKBAR;
60extern Atom a_NET_WM_STATE_SKIP_PAGER;
61extern Atom a_NET_WM_STATE_STICKY;
62extern Atom a_NET_WM_STATE_HIDDEN;
63extern Atom a_NET_WM_STATE_SHADED;
64
65#define a_NET_WM_STATE_REMOVE 0 /* remove/unset property */
66#define a_NET_WM_STATE_ADD 1 /* add/set property */
67#define a_NET_WM_STATE_TOGGLE 2 /* toggle property */
68
69extern Atom a_NET_WM_WINDOW_TYPE;
70extern Atom a_NET_WM_WINDOW_TYPE_DESKTOP;
71extern Atom a_NET_WM_WINDOW_TYPE_DOCK;
72extern Atom a_NET_WM_WINDOW_TYPE_TOOLBAR;
73extern Atom a_NET_WM_WINDOW_TYPE_MENU;
74extern Atom a_NET_WM_WINDOW_TYPE_UTILITY;
75extern Atom a_NET_WM_WINDOW_TYPE_SPLASH;
76extern Atom a_NET_WM_WINDOW_TYPE_DIALOG;
77extern Atom a_NET_WM_WINDOW_TYPE_NORMAL;
78
79extern Atom a_NET_WM_DESKTOP;
80extern Atom a_NET_WM_NAME;
81extern Atom a_NET_WM_VISIBLE_NAME;
82extern Atom a_NET_WM_STRUT;
83extern Atom a_NET_WM_STRUT_PARTIAL;
84extern Atom a_NET_WM_ICON;
85extern Atom a_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR;
86
87extern Atom a_NET_SYSTEM_TRAY_OPCODE;
88extern Atom a_NET_SYSTEM_TRAY_MESSAGE_DATA;
89extern Atom a_NET_SYSTEM_TRAY_ORIENTATION;
90extern Atom a_MANAGER;
91
92extern Atom a_LXPANEL_CMD; /* for private client message */
93
94/* Decoded value of WM_STATE property. */
6cc5e1a6 95typedef struct {
6b775dbb
AG
96 unsigned int modal : 1;
97 unsigned int sticky : 1;
98 unsigned int maximized_vert : 1;
99 unsigned int maximized_horz : 1;
100 unsigned int shaded : 1;
101 unsigned int skip_taskbar : 1;
102 unsigned int skip_pager : 1;
103 unsigned int hidden : 1;
104 unsigned int fullscreen : 1;
105 unsigned int above : 1;
106 unsigned int below : 1;
107} NetWMState;
108
109/* Decoded value of _NET_WM_WINDOW_TYPE property. */
6cc5e1a6 110typedef struct {
6b775dbb
AG
111 unsigned int desktop : 1;
112 unsigned int dock : 1;
113 unsigned int toolbar : 1;
114 unsigned int menu : 1;
115 unsigned int utility : 1;
116 unsigned int splash : 1;
117 unsigned int dialog : 1;
118 unsigned int normal : 1;
119} NetWMWindowType;
6cc5e1a6 120
2ba86315 121void Xclimsg(Window win, Atom type, long l0, long l1, long l2, long l3, long l4);
6cc5e1a6
DB
122void Xclimsgwm(Window win, Atom type, Atom arg);
123void *get_xaproperty (Window win, Atom prop, Atom type, int *nitems);
124char *get_textproperty(Window win, Atom prop);
125void *get_utf8_property(Window win, Atom atom);
126char **get_utf8_property_list(Window win, Atom atom, int *count);
127
128void resolve_atoms();
129//Window Select_Window(Display *dpy);
130int get_net_number_of_desktops();
131int get_net_current_desktop ();
132int get_net_wm_desktop(Window win);
133int get_wm_state (Window win);
134void get_net_wm_state(Window win, NetWMState *nws);
135void get_net_wm_window_type(Window win, NetWMWindowType *nwwt);
136GPid get_net_wm_pid(Window win);
137
6b775dbb
AG
138/**
139 * panel_handle_x_error
140 * @d: X display
141 * @ev: X error event
142 *
143 * Prints X error message to stderr if logging was enabled.
144 */
145extern int panel_handle_x_error(Display * d, XErrorEvent * ev);
146extern int panel_handle_x_error_swallow_BadWindow_BadDrawable(Display * d, XErrorEvent * ev);
147
f7ecd6ce
AG
148/**
149 * expand_tilda
150 * @file: file path
151 *
152 * If first char of @file is a tilda (~) then replaces it with content of
153 * environment variable HOME.
154 *
155 * Returns: (transfer full): new allocated path string.
156 */
6b775dbb 157gchar *expand_tilda(const gchar *file);
2ba86315 158
f7ecd6ce
AG
159/**
160 * gcolor2rgb24
161 * @color: a color structure
162 *
163 * Creates integer @color representation which can be easily converted
164 * into string using printf conversion "#%06x".
165 *
166 * Returns: a 32-bit integer.
167 */
6cc5e1a6 168guint32 gcolor2rgb24(GdkColor *color);
f7ecd6ce
AG
169
170/**
171 * lxpanel_button_new_for_icon
172 * @panel: panel instance
173 * @name: icon name or path
174 * @color: (allow-none): hilight color for icon
175 * @label: (allow-none): optional label for button
176 *
177 * Creates new #GtkEventBox button which will follow theme and icon size
178 * changes on @panel. If icon name is not found in theme then fallback
179 * name "application-x-executable" will be used. Button is flagged to be
180 * displayed.
181 *
182 * Returns: (transfer full): a new #GtkEventBox widget.
183 */
184extern GtkWidget *lxpanel_button_new_for_icon(LXPanel *panel, const gchar *name, GdkColor *color, const gchar *label);
185extern GtkWidget *lxpanel_button_new_for_fm_icon(LXPanel *panel, FmIcon *icon, GdkColor *color, const gchar *label);
186
187/**
188 * lxpanel_button_set_icon
189 * @btn: a button instance
190 * @name: icon name or path
191 * @size: new icon size
192 *
193 * Updates icon in the button created with lxpanel_button_new_for_icon()
194 * or lxpanel_button_new_for_fm_icon() before. If @size > 0 then stop
195 * following panel icon size and use this fixed size, if @size is 0 then
196 * do no changes on icons size.
197 */
198extern void lxpanel_button_set_icon(GtkWidget* btn, const gchar *name, gint size);
199extern void lxpanel_button_update_icon(GtkWidget* btn, FmIcon *icon, gint size);
200
201/**
202 * lxpanel_button_set_label
203 * @btn: a button instance
204 * @label: new label text
205 *
206 * Changes text of label created with lxpanel_button_new_for_icon(),
207 * lxpanel_button_new_for_fm_icon(), or lxpanel_button_compose(). Does
208 * nothing if those API were called with NULL passed as label.
209 *
210 * Returns: %TRUE in case of success.
211 *
212 * Since: 0.8.0
213 */
214extern gboolean lxpanel_button_set_label(GtkWidget *btn, const char *label);
215
216/**
217 * lxpanel_button_compose
218 * @event_box: a widget to add image and label
219 * @image: an image widget
220 * @color: (allow-none): hilight color for icon
221 * @label: (allow-none): optional label for button
222 *
223 * Composes button similarly to lxpanel_button_new_for_icon() but using
224 * existing container @event_box and @image. The @image should be created
225 * using lxpanel_image_new_for_icon() or lxpanel_image_new_for_fm_icon(),
226 * and it can be updated later using lxpanel_button_set_icon() API.
227 *
228 * Returns: (transfer none): @event_box.
229 *
230 * Since: 0.8.0
231 */
232extern GtkWidget *lxpanel_button_compose(GtkWidget *event_box, GtkWidget *image,
233 GdkColor *color, const gchar *label);
234
235/**
236 * lxpanel_image_new_for_icon
237 * @panel: (allow-none): panel instance
238 * @name: icon name or image path
239 * @height: image size
240 * @fallback: (allow-none): fallback image name or path
241 *
242 * Creates new #GtkImage which will follow theme if @name is a themed
243 * icon name. If @height is -1 then created image will also follow icon
244 * size changes on @panel. If icon not found in theme and @fallback is
245 * not %NULL then it will be used to load icon or image. Otherwise the
246 * "application-x-executable" will be used as fallback.
247 *
248 * Returns: (transfer full): a new #GtkImage widget.
249 *
250 * Since: 0.8.0
251 */
252extern GtkWidget *lxpanel_image_new_for_icon(LXPanel *panel, const gchar *name,
253 gint height, const gchar *fallback);
254extern GtkWidget *lxpanel_image_new_for_fm_icon(LXPanel *panel, FmIcon *icon,
255 gint height, const gchar *fallback);
256
257/**
258 * lxpanel_image_change_icon
259 * @img: an image
260 * @name: icon name or image path
261 * @fallback: (allow-none): fallback image name or path
262 *
263 * Changes an image @img created by lxpanel_image_new_for_icon() to use
264 * new icon @name and @fallback.
265 *
266 * Returns: %TRUE.
267 *
268 * Since: 0.8.0
269 */
270extern gboolean lxpanel_image_change_icon(GtkWidget *img, const gchar *name,
271 const char *fallback);
7486d297 272
6b775dbb 273G_END_DECLS
6cc5e1a6
DB
274
275#endif