panel-widget.h 5.95 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 20
#define PANEL_MAX 1000 /*10,000 long screen, FIXME! make dynamic*/

21
#define PANEL_APPLET_PARENT_KEY "panel_applet_parent_key"
22
#define PANEL_APPLET_ASSOC_PANEL_KEY "panel_applet_assoc_panel_key"
23
#define PANEL_APPLET_DATA "panel_applet_data"
24

25 26 27 28
typedef struct _PanelWidget		PanelWidget;
typedef struct _PanelWidgetClass	PanelWidgetClass;

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

struct _AppletRecord
{
65
	GtkWidget		*applet;
66
	gint			cells;
67 68
};

69 70
struct _AppletData
{
71 72 73 74
	GtkWidget *applet;
	gint pos;
	gint cells;

75 76 77 78 79 80
	gint prevx;
	gint prevy;
	gint prevwidth;
	gint prevheight;
};

81
struct _DNDRecord
82
{
83 84
	AppletRecord		*applet;
	GtkWidget		*parent;
85 86
};

87 88
struct _PanelWidget
{
89
	GtkWindow		window;
90

91
	GtkWidget		*frame;
92
	GtkWidget		*fixed;
93
	GtkWidget		*table;
94 95 96 97 98 99 100
	GtkWidget		*hidebutton_n;
	GtkWidget		*hidebutton_e;
	GtkWidget		*hidebutton_w;
	GtkWidget		*hidebutton_s;

	AppletRecord		applets[PANEL_MAX];
	gint	 		applet_count;
101
	GList			*applet_list;
102 103

	gint			size;
104 105 106 107
	PanelOrientation	orient;
	PanelSnapped		snapped;
	PanelMode		mode;
	PanelState		state;
108 109

	gint			leave_notify_timer_tag;
110

111 112
	AppletData		*currently_dragged_applet;
	gint			drag_blocked;
113

114
	DrawerDropZonePos	drawer_drop_zone_pos;
115 116
	gint			x;
	gint			y;
117

118
	gint			thick;
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
119 120 121 122 123

	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*/
124
	char                    *back_pixmap;
125
	gint			pixmap_enabled;
126 127 128 129
};

struct _PanelWidgetClass
{
130
	GtkWindowClass parent_class;
131 132 133 134 135 136

	void (* orient_change) (PanelWidget *panel,
				PanelOrientation orient,
				PanelSnapped snapped);
	void (* state_change) (PanelWidget *panel,
			       PanelState state);
137 138
	void (* applet_move) (PanelWidget *panel,
			      GtkWidget *applet);
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
139 140 141
	void (* applet_added) (PanelWidget *panel,
			       GtkWidget *applet);
	void (* applet_removed) (PanelWidget *panel);
142 143 144
};

guint		panel_widget_get_type		(void);
145
GtkWidget*	panel_widget_new		(gint size,
146 147 148
						 PanelOrientation orient,
						 PanelSnapped snapped,
						 PanelMode mode,
149
						 PanelState state,
150
						 gint pos_x,
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
151
						 gint pos_y,
152 153
						 DrawerDropZonePos
						 	drop_zone_pos,
154 155
						 char *back_pixmap);

156
/*add an applet to the panel, preferably at position pos*/
157 158 159
gint		panel_widget_add		(PanelWidget *panel,
						 GtkWidget *applet,
						 gint pos);
160
/*move applet to newpos*/
161
gint		panel_widget_move		(PanelWidget *panel,
162
						 GtkWidget *applet,
163 164
						 gint pos);

165
/*remove an applet from the panel*/
166 167
gint		panel_widget_remove		(PanelWidget *panel,
						 GtkWidget *applet);
168 169 170 171 172 173

/*move applet to a different panel*/
gint		panel_widget_reparent		(PanelWidget *old_panel,
						 PanelWidget *new_panel,
						 GtkWidget *applet,
						 gint pos);
174 175
/*return position of an applet*/
gint		panel_widget_get_pos		(PanelWidget *panel,
176
						 GtkWidget *applet);
177 178 179 180 181 182
/*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);
183 184 185 186 187 188

/*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);

189 190 191 192 193 194


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

195
/*drag*/
196 197
void		panel_widget_applet_drag_start	(PanelWidget *panel,
						 GtkWidget *applet);
198
void		panel_widget_applet_drag_end	(PanelWidget *panel);
199

200
/* needed for corba */
201 202 203
void		panel_widget_applet_drag_start_no_grab(PanelWidget *panel,
						       GtkWidget *applet);
void		panel_widget_applet_drag_end_no_grab(PanelWidget *panel);
204
gint		panel_widget_applet_move_to_cursor(PanelWidget *panel);
205 206
void		panel_widget_applet_move_use_idle(PanelWidget *panel);

207
/* changing parameters */
208 209 210 211 212
void		panel_widget_change_params	(PanelWidget *panel,
						 PanelOrientation orient,
						 PanelSnapped snapped,
						 PanelMode mode,
						 PanelState state,
213 214
						 DrawerDropZonePos
						 	drop_zone_pos,
215
						 char *pixmap_name);
216

217
/* changing parameters (orient only) */
218 219
void		panel_widget_change_orient	(PanelWidget *panel,
						 PanelOrientation orient);
220 221 222 223
/*changing parameters (dropzonepos only)*/
void		panel_widget_change_drop_zone_pos(PanelWidget *panel,
						  DrawerDropZonePos
						 	drop_zone_pos);
224

225 226 227 228
/*change global params*/
void		panel_widget_change_global	(gint explicit_step,
						 gint auto_step,
						 gint minimized_size,
229 230
						 gint minimize_delay,
						 PanelMovementType move_type);
231

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

235 236 237
void		panel_widget_enable_buttons	(PanelWidget *panel);
void		panel_widget_disable_buttons	(PanelWidget *panel);

238 239 240 241
void		panel_widget_set_drawer_pos	(PanelWidget *panel,
						 gint x,
						 gint y);

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

243 244
extern GList *panels;

245 246
extern gint panel_applet_in_drag;

247 248 249 250 251 252
#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif /* __PANEL_WIDGET_H__ */