Add support for monitors "All" to span panel over all monitors.
[lxde/lxpanel.git] / src / private.h
CommitLineData
b31cb1d2 1/**
b840f7cc 2 * Copyright (c) 2006-2014 LxDE Developers, see the file AUTHORS for details.
b31cb1d2
AG
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 PRIVATE_H
20#define PRIVATE_H
21
17fab6e5
AG
22#include "plugin.h"
23#include "conf.h"
b31cb1d2
AG
24
25#include <gmodule.h>
26
27#include <gtk/gtk.h>
28#include <gdk/gdk.h>
29#include <stdio.h>
30#include "panel.h"
31
32#include <gdk/gdk.h>
33
34#include "bg.h"
35#include "ev.h"
36
06e29ce1
AG
37#if !GLIB_CHECK_VERSION(2, 40, 0)
38# define g_info(...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, __VA_ARGS__)
39#endif
40
908d9fdc
AG
41/* -----------------------------------------------------------------------------
42 * Definitions used by lxpanel main code internally */
43
b31cb1d2
AG
44/* Extracted from panel.h */
45enum { ALLIGN_NONE, ALLIGN_LEFT, ALLIGN_CENTER, ALLIGN_RIGHT };
46enum { EDGE_NONE=0, EDGE_LEFT, EDGE_RIGHT, EDGE_TOP, EDGE_BOTTOM };
47enum { WIDTH_NONE, WIDTH_REQUEST, WIDTH_PIXEL, WIDTH_PERCENT };
48enum { HEIGHT_NONE, HEIGHT_PIXEL, HEIGHT_REQUEST };
b31cb1d2
AG
49
50#define PANEL_ICON_SIZE 24 /* Default size of panel icons */
51#define PANEL_HEIGHT_DEFAULT 26 /* Default height of horizontal panel */
52#define PANEL_WIDTH_DEFAULT 150 /* Default "height" of vertical panel */
53#define PANEL_HEIGHT_MAX 200 /* Maximum height of panel */
54#define PANEL_HEIGHT_MIN 16 /* Minimum height of panel */
55#define PANEL_ICON_HIGHLIGHT 0x202020 /* Constant to pass to icon loader */
56
57/* to check if we are in LXDE */
58extern gboolean is_in_lxde;
59
6a570f04
AG
60extern gchar *cprofile;
61
46c7d227
AG
62extern GSList* all_panels;
63
64extern GtkWindowGroup* win_grp;
65
b31cb1d2
AG
66/* Context of a panel on a given edge. */
67struct _Panel {
68 char* name;
a7bd16a4 69 LXPanel * topgwin; /* Main panel window */
b31cb1d2
AG
70 Window topxwin; /* Main panel's X window */
71 GdkDisplay * display; /* Main panel's GdkDisplay */
72 GtkStyle * defstyle;
73 GtkIconTheme* icon_theme; /*Default icon theme*/
74
75 GtkWidget * box; /* Top level widget */
76
77 GtkRequisition requisition;
78 GtkWidget *(*my_box_new) (gboolean, gint);
79 GtkWidget *(*my_separator_new) ();
80
81 FbBg *bg;
82 int alpha;
83 guint32 tintcolor;
84 guint32 fontcolor;
85 GdkColor gtintcolor;
86 GdkColor gfontcolor;
87
88 int ax, ay, aw, ah; /* prefferd allocation of a panel */
89 int cx, cy, cw, ch; /* current allocation (as reported by configure event) allocation */
90 int allign, edge, margin;
cfde283a 91 guint orientation;
b31cb1d2
AG
92 int widthtype, width;
93 int heighttype, height;
94 gint monitor;
95 gulong strut_size; /* Values for WM_STRUT_PARTIAL */
96 gulong strut_lower;
97 gulong strut_upper;
98 int strut_edge;
99
100 guint config_changed : 1;
101 guint self_destroy : 1;
102 guint setdocktype : 1;
103 guint setstrut : 1;
104 guint round_corners : 1;
105 guint usefontcolor : 1;
106 guint usefontsize : 1;
0bcf9045 107 guint fontsize;
b31cb1d2
AG
108 guint transparent : 1;
109 guint background : 1;
110 guint spacing;
111
112 guint autohide : 1;
113 guint visible : 1;
114 int height_when_hidden;
115 guint hide_timeout;
116 int icon_size; /* Icon size */
117
118 int desknum;
119 int curdesk;
0bfcc6c9 120 gulong *workarea;
b31cb1d2
AG
121 int wa_len;
122
123 char* background_file;
124
17fab6e5 125 PanelConf * config; /* Panel configuration data */
dd731fde 126 GSList * system_menus; /* List of plugins having menus: deprecated */
b31cb1d2
AG
127
128 GtkWidget* plugin_pref_dialog; /* Plugin preference dialog */
129 GtkWidget* pref_dialog; /* preference dialog */
130 GtkWidget* margin_control; /* Margin control in preference dialog */
131 GtkWidget* height_label; /* Label of height control */
132 GtkWidget* width_label; /* Label of width control */
133 GtkWidget* alignment_left_label; /* Label of alignment: left control */
134 GtkWidget* alignment_right_label; /* Label of alignment: right control */
135 GtkWidget* height_control; /* Height control in preference dialog */
136 GtkWidget* width_control; /* Width control in preference dialog */
de5a8e6c 137
5eaabb1b
AG
138 guint initialized : 1; /* Should be grouped better later, */
139 guint ah_far : 1; /* placed here for binary compatibility */
140 guint ah_state : 3;
50928868 141 guint background_update_queued;
5eaabb1b 142 guint mouse_timeout;
de5a8e6c
AG
143 //gint dyn_space; /* Space for expandable plugins */
144 //guint calculate_size_idle; /* The idle handler for dyn_space calc */
b31cb1d2
AG
145};
146
147typedef struct {
148 char *name;
149 char *disp_name;
150 void (*cmd)(void);
151} Command;
152
b31cb1d2
AG
153#define FBPANEL_WIN(win) gdk_window_lookup(win)
154
b31cb1d2 155/* Extracted from misc.h */
b31cb1d2
AG
156typedef struct {
157 int num;
158 gchar *str;
159} pair;
160
161extern pair allign_pair[];
162extern pair edge_pair[];
163extern pair width_pair[];
164extern pair height_pair[];
165extern pair bool_pair[];
b31cb1d2 166
17fab6e5
AG
167int str2num(pair *p, const gchar *str, int defval);
168const gchar *num2str(pair *p, int num, const gchar *defval);
b31cb1d2 169
1f4bc3aa 170#ifdef __LXPANEL_INTERNALS__
8ea02629 171static inline char *_system_config_file_name(const char *dir, const char *file_name)
1f4bc3aa 172{
9b37578a 173 return g_build_filename(dir, "lxpanel", cprofile, file_name, NULL);
1f4bc3aa
AG
174}
175
176static inline char *_old_system_config_file_name(const char *file_name)
177{
178 return g_build_filename(PACKAGE_DATA_DIR "/profile", cprofile, file_name, NULL);
179}
180
181static inline char *_user_config_file_name(const char *name1, const char *name2)
182{
183 return g_build_filename(g_get_user_config_dir(), "lxpanel", cprofile, name1,
184 name2, NULL);
185}
186#endif
908d9fdc 187
de5a8e6c
AG
188//void _queue_panel_calculate_size(Panel *panel);
189
049061d8
AG
190/* FIXME: optional definitions */
191#define STATIC_SEPARATOR
192#define STATIC_LAUNCHBAR
89930ab6 193#define STATIC_LAUNCHTASKBAR
049061d8
AG
194#define STATIC_DCLOCK
195#define STATIC_WINCMD
196#define STATIC_DIRMENU
197#define STATIC_TASKBAR
198#define STATIC_PAGER
199#define STATIC_TRAY
200#define STATIC_MENU
201#define STATIC_SPACE
202#define STATIC_ICONS
203
204/* Plugins management - new style */
205void _prepare_modules(void);
206void _unload_modules(void);
207
a7bd16a4 208GtkWidget *lxpanel_add_plugin(LXPanel *p, const char *name, config_setting_t *cfg, gint at);
049061d8
AG
209GHashTable *lxpanel_get_all_types(void); /* transfer none */
210
752ee4e2 211extern GQuark lxpanel_plugin_qinit; /* access to LXPanelPluginInit data */
049061d8
AG
212#define PLUGIN_CLASS(_i) ((LXPanelPluginInit*)g_object_get_qdata(G_OBJECT(_i),lxpanel_plugin_qinit))
213
752ee4e2 214extern GQuark lxpanel_plugin_qconf; /* access to congig_setting_t data */
049061d8 215
a7bd16a4 216#define PLUGIN_PANEL(_i) ((LXPanel*)gtk_widget_get_toplevel(_i))
908d9fdc 217
191694fb 218gboolean _class_is_present(const LXPanelPluginInit *init);
10d93053 219
46c7d227
AG
220LXPanel* panel_new(const char* config_file, const char* config_name);
221
a7bd16a4
AG
222void _panel_show_config_dialog(LXPanel *panel, GtkWidget *p, GtkWidget *dlg);
223
224void _calculate_position(LXPanel *panel);
225
226void _panel_determine_background_pixmap(LXPanel * p, GtkWidget * widget);
227void _panel_establish_autohide(LXPanel *p);
228void _panel_set_wm_strut(LXPanel *p);
229void _panel_set_panel_configuration_changed(LXPanel *p);
50928868 230void _panel_queue_update_background(LXPanel *p);
131514c9 231
adf42c84
AG
232void panel_configure(LXPanel* p, int sel_page);
233gboolean panel_edge_available(Panel* p, int edge, gint monitor);
234void restart(void);
235void logout(void);
236void gtk_run(void);
237
ca4eee75
AG
238/*
239 * creates GtkButton subclass which can change, test and apply global hotkey
240 * emits "changed" signal: void callback(LXHotkeyButton *, char *, gpointer);
241 */
242/*
243GtkWidget *_config_hotkey_button_new(const char *hotkey);
244*/
245
908d9fdc
AG
246/* -----------------------------------------------------------------------------
247 * Deprecated declarations. Kept for compatibility with old code plugins.
248 * Should be removed and appropriate code cleaned on some of next releases. */
249
adf42c84
AG
250extern Command commands[];
251
8dfa5918 252/* Extracted from panel.h */
f9e8104e
AG
253extern int verbose;
254
a7bd16a4
AG
255extern void panel_destroy(Panel *p);
256extern void panel_adjust_geometry_terminology(Panel *p);
257extern void panel_determine_background_pixmap(Panel * p, GtkWidget * widget, GdkWindow * window);
258extern void panel_draw_label_text(Panel * p, GtkWidget * label, const char * text,
259 gboolean bold, float custom_size_factor,
260 gboolean custom_color);
261extern void panel_establish_autohide(Panel *p);
262extern void panel_image_set_from_file(Panel * p, GtkWidget * image, const char * file);
263extern gboolean panel_image_set_icon_theme(Panel * p, GtkWidget * image, const gchar * icon);
264extern void panel_set_wm_strut(Panel *p);
265extern void panel_set_dock_type(Panel *p);
266extern void panel_set_panel_configuration_changed(Panel *p);
267extern void panel_update_background( Panel* p );
268
f9e8104e
AG
269/* if current window manager is EWMH conforming. */
270extern gboolean is_ewmh_supported;
271
272/*
273 This function is used to re-create a new box with different
274 orientation from the old one, add all children of the old one to
275 the new one, and then destroy the old box.
276 It's mainly used when we need to change the orientation of the panel or
277 any plugin with a layout box. Since GtkHBox cannot be changed to GtkVBox,
278 recreating a new box to replace the old one is required.
279*/
280GtkWidget* recreate_box( GtkBox* oldbox, GtkOrientation orientation );
281
8dfa5918
AG
282extern const char* lxpanel_get_file_manager();
283
284
908d9fdc
AG
285/* Extracted from misc.h */
286typedef struct _Plugin Plugin;
287
288enum { LINE_NONE, LINE_BLOCK_START, LINE_BLOCK_END, LINE_VAR };
289
290typedef struct {
291 int num, len, type;
292 gchar str[256];
293 gchar *t[3];
294} line;
295
a7bd16a4 296void calculate_position(Panel *np);
908d9fdc 297
b31cb1d2
AG
298extern int lxpanel_get_line(char **fp, line *s);
299extern int lxpanel_put_line(FILE* fp, const char* format, ...);
300#define lxpanel_put_str(fp, name, val) (G_UNLIKELY( !(val) || !*(val) )) ? 0 : lxpanel_put_line(fp, "%s=%s", name, val)
301#define lxpanel_put_bool(fp, name, val) lxpanel_put_line(fp, "%s=%c", name, (val) ? '1' : '0')
302#define lxpanel_put_int(fp, name, val) lxpanel_put_line(fp, "%s=%d", name, val)
b31cb1d2
AG
303
304GtkWidget *_gtk_image_new_from_file_scaled(const gchar *file, gint width,
305 gint height, gboolean keep_ratio);
306
c8e5ebb2
AG
307GtkWidget * fb_button_new_from_file(
308 const gchar * image_file, int width, int height, gulong highlight_color, gboolean keep_ratio);
309GtkWidget * fb_button_new_from_file_with_label(
dd731fde 310 const gchar * image_file, int width, int height, gulong highlight_color, gboolean keep_ratio, Panel * panel, const gchar * label);
c8e5ebb2
AG
311
312void fb_button_set_from_file(GtkWidget* btn, const char* img_file, gint width, gint height, gboolean keep_ratio);
313
b31cb1d2
AG
314char* translate_exec_to_cmd( const char* exec, const char* icon,
315 const char* title, const char* fpath );
316
317void show_error( GtkWindow* parent_win, const char* msg );
318
aaaef690
AG
319gboolean spawn_command_async(GtkWindow *parent_window, gchar const* workdir,
320 gchar const* cmd);
321
b31cb1d2
AG
322/* Parameters: const char* name, gpointer ret_value, GType type, ....NULL */
323GtkWidget* create_generic_config_dlg( const char* title, GtkWidget* parent,
324 GSourceFunc apply_func, Plugin * plugin,
325 const char* name, ... );
326
327extern GtkMenu* lxpanel_get_panel_menu( Panel* panel, Plugin* plugin, gboolean use_sub_menu );
328
329gboolean lxpanel_launch_app(const char* exec, GList* files, gboolean in_terminal, char const* in_workdir);
330
63e2d9e5
AG
331extern GdkPixbuf* lxpanel_load_icon( const char* name, int width, int height, gboolean use_fallback );
332
b31cb1d2
AG
333
334/* Extracted from plugin.h */
335struct _Plugin;
336
337/* Support for external plugin versioning.
338 * Plugins must invoke PLUGINCLASS_VERSIONING when they instantiate PluginClass. */
339#define PLUGINCLASS_VERSION 1
340#define PLUGINCLASS_VERSIONING \
341 .structure_size = sizeof(PluginClass), \
342 .structure_version = PLUGINCLASS_VERSION
343
344/* Representative of an available plugin. */
345typedef struct {
346
347 /* Keep these first. Do not make unnecessary changes in structure layout. */
348 unsigned short structure_size; /* Structure size, for versioning support */
349 unsigned short structure_version; /* Structure version, for versioning support */
350
351 char * fname; /* Plugin file pathname */
352 int count; /* Reference count */
353 GModule * gmodule; /* Associated GModule structure */
354
355 int dynamic : 1; /* True if dynamically loaded */
356 int unused_invisible : 1; /* Unused; reserved bit */
357 int not_unloadable : 1; /* Not unloadable due to GModule restriction */
358 int one_per_system : 1; /* Special: only one possible per system, such as system tray */
359 int one_per_system_instantiated : 1; /* True if one instance exists */
360 int expand_available : 1; /* True if "stretch" option is available */
361 int expand_default : 1; /* True if "stretch" option is default */
362
363 /* These fields point within the plugin image. */
364 char * type; /* Internal name of plugin, to match external filename */
365 char * name; /* Display name of plugin for selection UI */
366 char * version; /* Version of plugin */
367 char * description; /* Brief textual description of plugin for selection UI */
368
369 int (*constructor)(struct _Plugin * plugin, char ** fp); /* Create an instance of the plugin */
370 void (*destructor)(struct _Plugin * plugin); /* Destroy an instance of the plugin */
371 void (*config)(struct _Plugin * plugin, GtkWindow * parent); /* Request the plugin to display its configuration dialog */
372 void (*save)(struct _Plugin * plugin, FILE * fp); /* Request the plugin to save its configuration to a file */
373 void (*panel_configuration_changed)(struct _Plugin * plugin); /* Request the plugin to do a full redraw after a panel configuration change */
374} PluginClass;
375
376/* Representative of a loaded and active plugin attached to a panel. */
377struct _Plugin {
378 PluginClass * class; /* Back pointer to PluginClass */
379 Panel * panel; /* Back pointer to Panel */
380 GtkWidget * pwid; /* Top level widget; plugin allocates, but plugin mechanism, not plugin itself, destroys this */
381 int expand; /* Expand ("stretch") setting for container */
382 int padding; /* Padding setting for container */
383 int border; /* Border setting for container */
384 gpointer priv; /* Private context for plugin; plugin frees this in its destructor */
385};
386
387/* Plugins management - deprecated style, for backward compatibility */
b31cb1d2
AG
388extern gboolean plugin_button_press_event(GtkWidget *widget, GdkEventButton *event, Plugin *plugin);
389 /* Handler for "button_press_event" signal with Plugin as parameter */
390extern void plugin_adjust_popup_position(GtkWidget * popup, Plugin * plugin);
391 /* Helper to move popup windows away from the panel */
392extern void plugin_popup_set_position_helper(Plugin * p, GtkWidget * near, GtkWidget * popup, GtkRequisition * popup_req, gint * px, gint * py);
393 /* Helper for position-calculation callback for popup menus */
394
b31cb1d2 395#endif