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