Move recreate_box() into private.h header file.
[lxde/lxpanel.git] / src / private.h
CommitLineData
b31cb1d2
AG
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 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
908d9fdc
AG
37/* -----------------------------------------------------------------------------
38 * Definitions used by lxpanel main code internally */
39
b31cb1d2
AG
40/* Extracted from panel.h */
41enum { ALLIGN_NONE, ALLIGN_LEFT, ALLIGN_CENTER, ALLIGN_RIGHT };
42enum { EDGE_NONE=0, EDGE_LEFT, EDGE_RIGHT, EDGE_TOP, EDGE_BOTTOM };
43enum { WIDTH_NONE, WIDTH_REQUEST, WIDTH_PIXEL, WIDTH_PERCENT };
44enum { HEIGHT_NONE, HEIGHT_PIXEL, HEIGHT_REQUEST };
45enum {
46 ORIENT_NONE = -1,
47 ORIENT_VERT = GTK_ORIENTATION_VERTICAL,
48 ORIENT_HORIZ = GTK_ORIENTATION_HORIZONTAL
49};
b31cb1d2
AG
50
51#define PANEL_ICON_SIZE 24 /* Default size of panel icons */
52#define PANEL_HEIGHT_DEFAULT 26 /* Default height of horizontal panel */
53#define PANEL_WIDTH_DEFAULT 150 /* Default "height" of vertical panel */
54#define PANEL_HEIGHT_MAX 200 /* Maximum height of panel */
55#define PANEL_HEIGHT_MIN 16 /* Minimum height of panel */
56#define PANEL_ICON_HIGHLIGHT 0x202020 /* Constant to pass to icon loader */
57
58/* to check if we are in LXDE */
59extern gboolean is_in_lxde;
60
61/* Context of a panel on a given edge. */
62struct _Panel {
63 char* name;
64 GtkWidget * topgwin; /* Main panel window */
65 Window topxwin; /* Main panel's X window */
66 GdkDisplay * display; /* Main panel's GdkDisplay */
67 GtkStyle * defstyle;
68 GtkIconTheme* icon_theme; /*Default icon theme*/
69
70 GtkWidget * box; /* Top level widget */
71
72 GtkRequisition requisition;
73 GtkWidget *(*my_box_new) (gboolean, gint);
74 GtkWidget *(*my_separator_new) ();
75
76 FbBg *bg;
77 int alpha;
78 guint32 tintcolor;
79 guint32 fontcolor;
80 GdkColor gtintcolor;
81 GdkColor gfontcolor;
82
83 int ax, ay, aw, ah; /* prefferd allocation of a panel */
84 int cx, cy, cw, ch; /* current allocation (as reported by configure event) allocation */
85 int allign, edge, margin;
86 int orientation;
87 int widthtype, width;
88 int heighttype, height;
89 gint monitor;
90 gulong strut_size; /* Values for WM_STRUT_PARTIAL */
91 gulong strut_lower;
92 gulong strut_upper;
93 int strut_edge;
94
95 guint config_changed : 1;
96 guint self_destroy : 1;
97 guint setdocktype : 1;
98 guint setstrut : 1;
99 guint round_corners : 1;
100 guint usefontcolor : 1;
101 guint usefontsize : 1;
102 guint fontsize;
103 guint transparent : 1;
104 guint background : 1;
105 guint spacing;
106
107 guint autohide : 1;
108 guint visible : 1;
109 int height_when_hidden;
110 guint hide_timeout;
111 int icon_size; /* Icon size */
112
113 int desknum;
114 int curdesk;
115 guint32 *workarea;
116 int wa_len;
117
118 char* background_file;
119
b31cb1d2 120 GSList * system_menus; /* List of plugins having menus */
17fab6e5 121 PanelConf * config; /* Panel configuration data */
b31cb1d2
AG
122
123 GtkWidget* plugin_pref_dialog; /* Plugin preference dialog */
124 GtkWidget* pref_dialog; /* preference dialog */
125 GtkWidget* margin_control; /* Margin control in preference dialog */
126 GtkWidget* height_label; /* Label of height control */
127 GtkWidget* width_label; /* Label of width control */
128 GtkWidget* alignment_left_label; /* Label of alignment: left control */
129 GtkWidget* alignment_right_label; /* Label of alignment: right control */
130 GtkWidget* height_control; /* Height control in preference dialog */
131 GtkWidget* width_control; /* Width control in preference dialog */
132};
133
134typedef struct {
135 char *name;
136 char *disp_name;
137 void (*cmd)(void);
138} Command;
139
140extern Command commands[];
141
142extern FbEv *fbev;
143
144#define FBPANEL_WIN(win) gdk_window_lookup(win)
145
b31cb1d2 146/* Extracted from misc.h */
b31cb1d2
AG
147typedef struct {
148 int num;
149 gchar *str;
150} pair;
151
152extern pair allign_pair[];
153extern pair edge_pair[];
154extern pair width_pair[];
155extern pair height_pair[];
156extern pair bool_pair[];
b31cb1d2 157
17fab6e5
AG
158int str2num(pair *p, const gchar *str, int defval);
159const gchar *num2str(pair *p, int num, const gchar *defval);
b31cb1d2 160
908d9fdc
AG
161char* get_config_file( const char* profile, const char* file_name, gboolean is_global );
162
908d9fdc
AG
163
164/* -----------------------------------------------------------------------------
165 * Deprecated declarations. Kept for compatibility with old code plugins.
166 * Should be removed and appropriate code cleaned on some of next releases. */
167
8dfa5918 168/* Extracted from panel.h */
f9e8104e
AG
169extern int verbose;
170
171/* if current window manager is EWMH conforming. */
172extern gboolean is_ewmh_supported;
173
174/*
175 This function is used to re-create a new box with different
176 orientation from the old one, add all children of the old one to
177 the new one, and then destroy the old box.
178 It's mainly used when we need to change the orientation of the panel or
179 any plugin with a layout box. Since GtkHBox cannot be changed to GtkVBox,
180 recreating a new box to replace the old one is required.
181*/
182GtkWidget* recreate_box( GtkBox* oldbox, GtkOrientation orientation );
183
8dfa5918
AG
184extern const char* lxpanel_get_file_manager();
185
186
908d9fdc
AG
187/* Extracted from misc.h */
188typedef struct _Plugin Plugin;
189
190enum { LINE_NONE, LINE_BLOCK_START, LINE_BLOCK_END, LINE_VAR };
191
192typedef struct {
193 int num, len, type;
194 gchar str[256];
195 gchar *t[3];
196} line;
197
198
b31cb1d2
AG
199extern int lxpanel_get_line(char **fp, line *s);
200extern int lxpanel_put_line(FILE* fp, const char* format, ...);
201#define lxpanel_put_str(fp, name, val) (G_UNLIKELY( !(val) || !*(val) )) ? 0 : lxpanel_put_line(fp, "%s=%s", name, val)
202#define lxpanel_put_bool(fp, name, val) lxpanel_put_line(fp, "%s=%c", name, (val) ? '1' : '0')
203#define lxpanel_put_int(fp, name, val) lxpanel_put_line(fp, "%s=%d", name, val)
b31cb1d2
AG
204
205GtkWidget *_gtk_image_new_from_file_scaled(const gchar *file, gint width,
206 gint height, gboolean keep_ratio);
207
c8e5ebb2
AG
208GtkWidget * fb_button_new_from_file(
209 const gchar * image_file, int width, int height, gulong highlight_color, gboolean keep_ratio);
210GtkWidget * fb_button_new_from_file_with_label(
211 const gchar * image_file, int width, int height, gulong highlight_color, gboolean keep_ratio, Panel * panel, gchar * label);
212
213void fb_button_set_from_file(GtkWidget* btn, const char* img_file, gint width, gint height, gboolean keep_ratio);
214
b31cb1d2
AG
215char* translate_exec_to_cmd( const char* exec, const char* icon,
216 const char* title, const char* fpath );
217
218void show_error( GtkWindow* parent_win, const char* msg );
219
aaaef690
AG
220gboolean spawn_command_async(GtkWindow *parent_window, gchar const* workdir,
221 gchar const* cmd);
222
b31cb1d2
AG
223/* Parameters: const char* name, gpointer ret_value, GType type, ....NULL */
224GtkWidget* create_generic_config_dlg( const char* title, GtkWidget* parent,
225 GSourceFunc apply_func, Plugin * plugin,
226 const char* name, ... );
227
228extern GtkMenu* lxpanel_get_panel_menu( Panel* panel, Plugin* plugin, gboolean use_sub_menu );
229
230gboolean lxpanel_launch_app(const char* exec, GList* files, gboolean in_terminal, char const* in_workdir);
231
63e2d9e5
AG
232extern GdkPixbuf* lxpanel_load_icon( const char* name, int width, int height, gboolean use_fallback );
233
b31cb1d2
AG
234
235/* Extracted from plugin.h */
236struct _Plugin;
237
238/* Support for external plugin versioning.
239 * Plugins must invoke PLUGINCLASS_VERSIONING when they instantiate PluginClass. */
240#define PLUGINCLASS_VERSION 1
241#define PLUGINCLASS_VERSIONING \
242 .structure_size = sizeof(PluginClass), \
243 .structure_version = PLUGINCLASS_VERSION
244
245/* Representative of an available plugin. */
246typedef struct {
247
248 /* Keep these first. Do not make unnecessary changes in structure layout. */
249 unsigned short structure_size; /* Structure size, for versioning support */
250 unsigned short structure_version; /* Structure version, for versioning support */
251
252 char * fname; /* Plugin file pathname */
253 int count; /* Reference count */
254 GModule * gmodule; /* Associated GModule structure */
255
256 int dynamic : 1; /* True if dynamically loaded */
257 int unused_invisible : 1; /* Unused; reserved bit */
258 int not_unloadable : 1; /* Not unloadable due to GModule restriction */
259 int one_per_system : 1; /* Special: only one possible per system, such as system tray */
260 int one_per_system_instantiated : 1; /* True if one instance exists */
261 int expand_available : 1; /* True if "stretch" option is available */
262 int expand_default : 1; /* True if "stretch" option is default */
263
264 /* These fields point within the plugin image. */
265 char * type; /* Internal name of plugin, to match external filename */
266 char * name; /* Display name of plugin for selection UI */
267 char * version; /* Version of plugin */
268 char * description; /* Brief textual description of plugin for selection UI */
269
270 int (*constructor)(struct _Plugin * plugin, char ** fp); /* Create an instance of the plugin */
271 void (*destructor)(struct _Plugin * plugin); /* Destroy an instance of the plugin */
272 void (*config)(struct _Plugin * plugin, GtkWindow * parent); /* Request the plugin to display its configuration dialog */
273 void (*save)(struct _Plugin * plugin, FILE * fp); /* Request the plugin to save its configuration to a file */
274 void (*panel_configuration_changed)(struct _Plugin * plugin); /* Request the plugin to do a full redraw after a panel configuration change */
275} PluginClass;
276
277/* Representative of a loaded and active plugin attached to a panel. */
278struct _Plugin {
279 PluginClass * class; /* Back pointer to PluginClass */
280 Panel * panel; /* Back pointer to Panel */
281 GtkWidget * pwid; /* Top level widget; plugin allocates, but plugin mechanism, not plugin itself, destroys this */
282 int expand; /* Expand ("stretch") setting for container */
283 int padding; /* Padding setting for container */
284 int border; /* Border setting for container */
285 gpointer priv; /* Private context for plugin; plugin frees this in its destructor */
286};
287
288/* Plugins management - deprecated style, for backward compatibility */
b31cb1d2
AG
289extern gboolean plugin_button_press_event(GtkWidget *widget, GdkEventButton *event, Plugin *plugin);
290 /* Handler for "button_press_event" signal with Plugin as parameter */
291extern void plugin_adjust_popup_position(GtkWidget * popup, Plugin * plugin);
292 /* Helper to move popup windows away from the panel */
293extern void plugin_popup_set_position_helper(Plugin * p, GtkWidget * near, GtkWidget * popup, GtkRequisition * popup_req, gint * px, gint * py);
294 /* Helper for position-calculation callback for popup menus */
295
908d9fdc
AG
296
297/* -------------------------------------------------------------------------- */
b31cb1d2
AG
298/* FIXME: optional definitions */
299#define STATIC_SEPARATOR
300#define STATIC_LAUNCHBAR
301#define STATIC_DCLOCK
302#define STATIC_WINCMD
303#define STATIC_DIRMENU
304#define STATIC_TASKBAR
305#define STATIC_PAGER
306#define STATIC_TRAY
307#define STATIC_MENU
308#define STATIC_SPACE
309#define STATIC_ICONS
310
311/* Plugins management - new style */
17fab6e5
AG
312void _prepare_modules(void);
313void _unload_modules(void);
314
315GtkWidget *lxpanel_add_plugin(Panel *p, const char *name, config_setting_t *cfg, gint at);
316GHashTable *lxpanel_get_all_types(void); /* transfer none */
b31cb1d2
AG
317
318GQuark lxpanel_plugin_qinit; /* access to LXPanelPluginInit data */
17fab6e5 319#define PLUGIN_CLASS(_i) ((LXPanelPluginInit*)g_object_get_qdata(G_OBJECT(_i),lxpanel_plugin_qinit))
b31cb1d2
AG
320
321GQuark lxpanel_plugin_qconf; /* access to congig_setting_t data */
322
17fab6e5
AG
323GQuark lxpanel_plugin_qpanel; /* access to Panel */
324#define PLUGIN_PANEL(_i) ((Panel*)g_object_get_qdata(G_OBJECT(_i),lxpanel_plugin_qpanel))
325
b31cb1d2 326#endif