panel-widget.h 5.74 KB
Newer Older
1 2 3 4
#ifndef __PANEL_WIDGET_H__
#define __PANEL_WIDGET_H__


5
#include <gtk/gtk.h>
6 7 8 9 10 11 12 13 14 15

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */


#define PANEL_WIDGET(obj)          GTK_CHECK_CAST (obj, panel_widget_get_type (), PanelWidget)
#define PANEL_WIDGET_CLASS(klass)  GTK_CHECK_CLASS_CAST (klass, panel_widget_get_type (), PanelWidgetClass)
#define IS_PANEL_WIDGET(obj)       GTK_CHECK_TYPE (obj, panel_widget_get_type ())

16
#define PANEL_CELL_SIZE 10
17
#define PANEL_MINIMUM_WIDTH 48
18

19
#define PANEL_APPLET_PARENT_KEY "panel_applet_parent_key"
20
#define PANEL_APPLET_ASSOC_PANEL_KEY "panel_applet_assoc_panel_key"
21
#define PANEL_APPLET_DATA "panel_applet_data"
22

23 24 25 26
typedef struct _PanelWidget		PanelWidget;
typedef struct _PanelWidgetClass	PanelWidgetClass;

typedef struct _AppletRecord		AppletRecord;
27
typedef struct _AppletData		AppletData;
28
typedef struct _DNDRecord		DNDRecord;
29 30 31 32
typedef enum {
	PANEL_HORIZONTAL,
	PANEL_VERTICAL
} PanelOrientation;
33 34
typedef enum {
	PANEL_FREE,
35
	PANEL_DRAWER,
36 37 38 39 40 41 42
	PANEL_TOP,
	PANEL_BOTTOM,
	PANEL_LEFT,
	PANEL_RIGHT
} PanelSnapped;
typedef enum {
	PANEL_EXPLICIT_HIDE,
43
	PANEL_AUTO_HIDE
44 45 46
} PanelMode;
typedef enum {
	PANEL_SHOWN,
47
	PANEL_MOVING,
48 49 50
	PANEL_HIDDEN,
	PANEL_HIDDEN_RIGHT,
	PANEL_HIDDEN_LEFT
51
} PanelState;
52
typedef enum {
53 54
	DROP_ZONE_LEFT,
	DROP_ZONE_RIGHT
55
} DrawerDropZonePos;
56 57 58 59
typedef enum {
	PANEL_SWITCH_MOVE,
	PANEL_FREE_MOVE
} PanelMovementType;
60

61 62
struct _AppletData
{
63 64 65 66
	GtkWidget *applet;
	gint pos;
	gint cells;

67 68 69 70 71 72
	gint prevx;
	gint prevy;
	gint prevwidth;
	gint prevheight;
};

73
struct _DNDRecord
74
{
75
	AppletData		*ad;
76
	GtkWidget		*parent;
77 78
};

79 80
struct _PanelWidget
{
81
	GtkWindow		window;
82

83
	GtkWidget		*frame;
84
	GtkWidget		*fixed;
85
	GtkWidget		*table;
86 87 88 89 90
	GtkWidget		*hidebutton_n;
	GtkWidget		*hidebutton_e;
	GtkWidget		*hidebutton_w;
	GtkWidget		*hidebutton_s;

91
	GList			*applet_list;
92 93

	gint			size;
94 95 96 97
	PanelOrientation	orient;
	PanelSnapped		snapped;
	PanelMode		mode;
	PanelState		state;
98 99

	gint			leave_notify_timer_tag;
100

101
	AppletData		*currently_dragged_applet;
102

103
	DrawerDropZonePos	drawer_drop_zone_pos;
104 105
	gint			x;
	gint			y;
106

107
	gint			thick;
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
108 109 110 111 112

	gint			drawers_open; /* a count which can be used
						 to block the autohide, until
						 it is 0 .. it's set by the
						 app not the widget*/
113
	char                    *back_pixmap;
114
	gint			pixmap_enabled;
115 116 117 118
};

struct _PanelWidgetClass
{
119
	GtkWindowClass parent_class;
120 121 122 123 124 125

	void (* orient_change) (PanelWidget *panel,
				PanelOrientation orient,
				PanelSnapped snapped);
	void (* state_change) (PanelWidget *panel,
			       PanelState state);
126 127
	void (* applet_move) (PanelWidget *panel,
			      GtkWidget *applet);
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
128 129 130
	void (* applet_added) (PanelWidget *panel,
			       GtkWidget *applet);
	void (* applet_removed) (PanelWidget *panel);
131 132 133
};

guint		panel_widget_get_type		(void);
134
GtkWidget*	panel_widget_new		(gint size,
135 136 137
						 PanelOrientation orient,
						 PanelSnapped snapped,
						 PanelMode mode,
138
						 PanelState state,
139
						 gint pos_x,
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
140
						 gint pos_y,
141 142
						 DrawerDropZonePos
						 	drop_zone_pos,
143 144
						 char *back_pixmap);

145
/*add an applet to the panel, preferably at position pos*/
146 147 148
gint		panel_widget_add		(PanelWidget *panel,
						 GtkWidget *applet,
						 gint pos);
149
/*move applet to newpos*/
150
gint		panel_widget_move		(PanelWidget *panel,
151
						 GtkWidget *applet,
152 153
						 gint pos);

154
/*remove an applet from the panel*/
155 156
gint		panel_widget_remove		(PanelWidget *panel,
						 GtkWidget *applet);
157 158 159 160 161 162

/*move applet to a different panel*/
gint		panel_widget_reparent		(PanelWidget *old_panel,
						 PanelWidget *new_panel,
						 GtkWidget *applet,
						 gint pos);
163 164
/*return position of an applet*/
gint		panel_widget_get_pos		(PanelWidget *panel,
165
						 GtkWidget *applet);
166 167 168 169 170 171
/*return a list of all applets*/
GList*		panel_widget_get_applets	(PanelWidget *panel);
/*run func for each applet*/
void		panel_widget_foreach		(PanelWidget *panel,
						 GFunc func,
						 gpointer user_data);
172 173 174 175 176 177

/*restore the current state, used after it was gtk_widget_hiden
  emits "restore_state" signal so you can propagate the restore
  state to drawers and such*/
void		panel_widget_restore_state	(PanelWidget *panel);

178 179 180 181 182 183


/*open and close drawers*/
void		panel_widget_open_drawer	(PanelWidget *panel);
void		panel_widget_close_drawer	(PanelWidget *panel);

184
/*drag*/
185 186
void		panel_widget_applet_drag_start	(PanelWidget *panel,
						 GtkWidget *applet);
187
void		panel_widget_applet_drag_end	(PanelWidget *panel);
188

189
/* needed for corba */
190 191 192
void		panel_widget_applet_drag_start_no_grab(PanelWidget *panel,
						       GtkWidget *applet);
void		panel_widget_applet_drag_end_no_grab(PanelWidget *panel);
193
gint		panel_widget_applet_move_to_cursor(PanelWidget *panel);
194 195
void		panel_widget_applet_move_use_idle(PanelWidget *panel);

196
/* changing parameters */
197 198 199 200 201
void		panel_widget_change_params	(PanelWidget *panel,
						 PanelOrientation orient,
						 PanelSnapped snapped,
						 PanelMode mode,
						 PanelState state,
202 203
						 DrawerDropZonePos
						 	drop_zone_pos,
204
						 char *pixmap_name);
205

206
/* changing parameters (orient only) */
207 208
void		panel_widget_change_orient	(PanelWidget *panel,
						 PanelOrientation orient);
209 210 211 212
/*changing parameters (dropzonepos only)*/
void		panel_widget_change_drop_zone_pos(PanelWidget *panel,
						  DrawerDropZonePos
						 	drop_zone_pos);
213

214 215 216 217
/*change global params*/
void		panel_widget_change_global	(gint explicit_step,
						 gint auto_step,
						 gint minimized_size,
218 219
						 gint minimize_delay,
						 PanelMovementType move_type);
220

Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
221 222 223
/*popup the widget if it's popped down (autohide)*/
void		panel_widget_pop_up		(PanelWidget *panel);

224 225 226
void		panel_widget_enable_buttons	(PanelWidget *panel);
void		panel_widget_disable_buttons	(PanelWidget *panel);

227 228 229 230
void		panel_widget_set_drawer_pos	(PanelWidget *panel,
						 gint x,
						 gint y);

Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
231

232 233
extern GList *panels;

234 235
extern gint panel_applet_in_drag;

236 237 238 239 240 241
#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif /* __PANEL_WIDGET_H__ */