panel-widget.h 5.02 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_DRAWER_DROP_TARGET_SIZE 5
22

23
#define PANEL_APPLET_PARENT_KEY "panel_applet_parent_key"
24
#define PANEL_APPLET_ASSOC_PANEL_KEY "panel_applet_assoc_panel_key"
25
#define PANEL_APPLET_DATA "panel_applet_data"
26

27 28 29 30
typedef struct _PanelWidget		PanelWidget;
typedef struct _PanelWidgetClass	PanelWidgetClass;

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

struct _AppletRecord
{
63
	GtkWidget		*applet;
64
	gint			cells;
65 66
};

67 68 69 70 71 72 73 74
struct _AppletData
{
	gint prevx;
	gint prevy;
	gint prevwidth;
	gint prevheight;
};

75
struct _DNDRecord
76
{
77 78
	AppletRecord		*applet;
	GtkWidget		*parent;
79 80
};

81 82
struct _PanelWidget
{
83
	GtkWindow		window;
84

85
	GtkWidget		*fixed;
86
	GtkWidget		*table;
87 88 89 90 91 92 93
	GtkWidget		*hidebutton_n;
	GtkWidget		*hidebutton_e;
	GtkWidget		*hidebutton_w;
	GtkWidget		*hidebutton_s;

	AppletRecord		applets[PANEL_MAX];
	gint	 		applet_count;
94 95

	gint			size;
96 97 98 99
	PanelOrientation	orient;
	PanelSnapped		snapped;
	PanelMode		mode;
	PanelState		state;
100 101

	gint			leave_notify_timer_tag;
102 103

	GtkWidget		*currently_dragged_applet;
104
	gint			currently_dragged_applet_pos;
105

106 107 108
	GtkWidget		*drawer_drop_zone;
	DrawerDropZonePos	drawer_drop_zone_pos;

109
	gint			thick;
110 111 112 113
};

struct _PanelWidgetClass
{
114
	GtkWindowClass parent_class;
115 116 117 118 119 120

	void (* orient_change) (PanelWidget *panel,
				PanelOrientation orient,
				PanelSnapped snapped);
	void (* state_change) (PanelWidget *panel,
			       PanelState state);
121 122
	void (* applet_move) (PanelWidget *panel,
			      GtkWidget *applet);
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
123 124 125
	void (* applet_added) (PanelWidget *panel,
			       GtkWidget *applet);
	void (* applet_removed) (PanelWidget *panel);
126 127 128
};

guint		panel_widget_get_type		(void);
129
GtkWidget*	panel_widget_new		(gint size,
130 131 132
						 PanelOrientation orient,
						 PanelSnapped snapped,
						 PanelMode mode,
133
						 PanelState state,
134
						 gint pos_x,
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
135 136 137
						 gint pos_y,
						 DrawerDropZonePos
						 	drop_zone_pos);
138
/*add an applet to the panel, preferably at position pos*/
139 140 141
gint		panel_widget_add		(PanelWidget *panel,
						 GtkWidget *applet,
						 gint pos);
142 143 144 145 146
/*move oldpos to newpos*/
gint		panel_widget_move		(PanelWidget *panel,
						 gint oldpos,
						 gint pos);

147
/*remove an applet from the panel*/
148 149
gint		panel_widget_remove		(PanelWidget *panel,
						 GtkWidget *applet);
150 151 152 153 154 155

/*move applet to a different panel*/
gint		panel_widget_reparent		(PanelWidget *old_panel,
						 PanelWidget *new_panel,
						 GtkWidget *applet,
						 gint pos);
156 157
/*return position of an applet*/
gint		panel_widget_get_pos		(PanelWidget *panel,
158
						 GtkWidget *applet);
159 160 161 162 163 164
/*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);
165 166 167 168 169 170

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

171 172 173 174 175 176


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

177 178 179
/*initiate drag*/
void		panel_widget_applet_drag_start	(PanelWidget *panel,
						 GtkWidget *applet);
180

181 182 183 184
/*needed for corba*/
void		panel_widget_applet_drag_start_no_grab(PanelWidget *panel,
						       GtkWidget *applet);
void		panel_widget_applet_drag_end_no_grab(PanelWidget *panel);
185
gint		panel_widget_applet_move_to_cursor(PanelWidget *panel);
186 187
void		panel_widget_applet_move_use_idle(PanelWidget *panel);

188 189 190 191 192 193
/*changing parameters*/
void		panel_widget_change_params	(PanelWidget *panel,
						 PanelOrientation orient,
						 PanelSnapped snapped,
						 PanelMode mode,
						 PanelState state,
Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
194 195
						 DrawerDropZonePos
						 	drop_zone_pos);
196

197 198 199 200
/*changing parameters (orient only)*/
void		panel_widget_change_orient	(PanelWidget *panel,
						 PanelOrientation orient);

201 202 203 204 205 206
/*change global params*/
void		panel_widget_change_global	(gint explicit_step,
						 gint auto_step,
						 gint minimized_size,
						 gint minimize_delay);

207 208
extern GList *panels;

209 210 211 212 213 214
#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif /* __PANEL_WIDGET_H__ */