panel-widget.h 6.5 KB
Newer Older
1
/* Gnome panel: panel widget
2
 * (C) 1997-1998 the Free Software Foundation
3 4 5
 *
 * Authors:  George Lebl
 */
6 7 8 9
/* This widget, although slightly written as a general purpose widget, it
   has MANY interdependencies, which makes it almost impossible to use in
   anything else but the panel, what it would need is some serious
   cleaning up*/
10 11
#ifndef PANEL_WIDGET_H
#define PANEL_WIDGET_H
12

13
#include <gtk/gtk.h>
14
#include <gdk-pixbuf/gdk-pixbuf.h>
15
#include "button-widget.h"
16
#include "panel-types.h"
17
#include "panel-toplevel.h"
18

19
G_BEGIN_DECLS
20

21 22 23 24
#define PANEL_TYPE_WIDGET          	(panel_widget_get_type ())
#define PANEL_WIDGET(object)          	(G_TYPE_CHECK_INSTANCE_CAST ((object), PANEL_TYPE_WIDGET, PanelWidget))
#define PANEL_WIDGET_CLASS(klass)  	(G_TYPE_CHECK_CLASS_CAST ((klass), PANEL_TYPE_WIDGET, PanelWidgetClass))
#define PANEL_IS_WIDGET(object)       	(G_TYPE_CHECK_INSTANCE_TYPE ((object), PANEL_TYPE_WIDGET)) 
25

26
#define PANEL_APPLET_DATA "panel_applet_data"
27

28
#ifndef TYPEDEF_PANEL_WIDGET
29
typedef struct _PanelWidget		PanelWidget;
30 31 32
#define TYPEDEF_PANEL_WIDGET
#endif /* TYPEDEF_PANEL_WIDGET */

33 34 35
typedef struct _PanelWidgetClass	PanelWidgetClass;

typedef struct _AppletRecord		AppletRecord;
36
typedef struct _AppletData		AppletData;
37
typedef struct _DNDRecord		DNDRecord;
38

39 40 41 42 43 44 45 46 47 48 49 50 51
typedef struct _AppletSizeHints		AppletSizeHints;
typedef struct _AppletSizeHintsAlloc	AppletSizeHintsAlloc;

struct _AppletSizeHints {
	int *hints;
	int  len;
};

struct _AppletSizeHintsAlloc {
	int index;
	int size;
};

52 53
struct _AppletData
{
54
	GtkWidget *	applet;
55 56 57 58 59 60

	PanelObjectPackType pack_type;
	int		    pack_index;

	/* constrained position from the left, after taking other objects into
	 * account */
61
	int             constrained;
62
	int		cells;
63 64
	int             min_cells;

65 66 67 68
	/* Valid size ranges for expanded applets */
	int *           size_hints; 
	int             size_hints_len;
  
69 70 71
	guint           size_constrained : 1;
	guint           expand_major : 1;
	guint           expand_minor : 1;
72 73
};

74 75
struct _PanelWidget
{
76
	GtkFixed        fixed;
77

78
	GList          *applet_list;
79

80
	GSList         *open_dialogs;	
81

82 83 84
	int             size;
	GtkOrientation  orient;
	int             sz;
85

86
	AppletData     *currently_dragged_applet;
87
	guint           dragged_state;
88

89 90 91 92
	GtkWidget      *drop_widget;     /* widget that the panel checks for
	                                  * the cursor on drops usually the
	                                  * panel widget itself
	                                  */
93
	
94
	PanelToplevel  *toplevel;
95
	
96 97
	GdkEventKey    *key_event;

98 99 100 101 102 103
	/* helpers to get a good size in packed panels with applets using
	 * size hints */
	int                   nb_applets_size_hints;
	AppletSizeHints      *applets_hints;
	AppletSizeHintsAlloc *applets_using_hint;

104
	guint           packed : 1;
105 106 107 108
};

struct _PanelWidgetClass
{
109
	GtkFixedClass parent_class;
110

111 112
	void (* applet_move) (PanelWidget *panel,
			      GtkWidget *applet);
113 114
	void (* applet_added) (PanelWidget *panel,
			       GtkWidget *applet);
115 116
	void (* applet_removed) (PanelWidget *panel,
				 GtkWidget *applet);
117 118 119 120
	void (* push_move) (PanelWidget		*panel,
                            GtkDirectionType	 dir);
	void (* switch_move) (PanelWidget	*panel,
                              GtkDirectionType	 dir);
121 122
	void (* tab_move) (PanelWidget	*panel,
                           gboolean	 next);
123
	void (* end_move) (PanelWidget	*panel);
124 125
};

Jiri (George) Lebl's avatar
Jiri (George) Lebl committed
126
GType		panel_widget_get_type		(void) G_GNUC_CONST;
127

128 129 130 131
GtkWidget *	panel_widget_new		(PanelToplevel  *toplevel,
						 gboolean        packed,
						 GtkOrientation  orient,
						 int             sz);
132 133 134
/* add an applet to the panel; if use_pack_index is FALSE, pack_index is ignored
 * and the applet is appended at the end of the pack list for pack_style */
void		panel_widget_add		(PanelWidget         *panel,
135 136
						 GtkWidget           *applet,
						 PanelObjectPackType  pack_style,
137 138
						 int                  pack_index,
						 gboolean             use_pack_index);
139

140
/*move applet to a different panel*/
141 142 143 144 145
int		panel_widget_reparent		(PanelWidget         *old_panel,
						 PanelWidget         *new_panel,
						 GtkWidget           *applet,
						 PanelObjectPackType  pack_type,
						 int                  pack_index);
146

147
/*drag*/
148
gboolean        panel_applet_is_in_drag         (void);
149
void		panel_widget_applet_drag_start	(PanelWidget *panel,
150 151
						 GtkWidget   *applet,
						 guint32      time_);
152
void		panel_widget_applet_drag_end	(PanelWidget *panel);
153

154 155 156 157 158 159
void            panel_widget_set_packed         (PanelWidget    *panel_widget,
						 gboolean        packed);
void            panel_widget_set_orientation    (PanelWidget    *panel_widget,
						 GtkOrientation  orientation);
void            panel_widget_set_size           (PanelWidget    *panel_widget,
						 int             size);
160

161
/*draw EVERYTHING (meaning icons)*/
162 163
void		panel_widget_draw_all		(PanelWidget *panel,
						 GdkRectangle *area);
164 165 166 167 168
/*draw just one icon (applet has to be an icon of course)*/
void		panel_widget_draw_icon		(PanelWidget *panel,
						 ButtonWidget *applet);


169
/*get pos of the cursor location in panel coordinates*/
170
int		panel_widget_get_cursorloc	(PanelWidget *panel);
171 172 173 174 175 176 177 178 179
/* get pack type & index for insertion at the cursor location in panel */
void            panel_widget_get_insert_at_cursor (PanelWidget         *widget,
						   PanelObjectPackType *pack_type,
						   int                 *pack_index);
/* get pack type for insertion at the cursor location in panel */
PanelObjectPackType panel_widget_get_insert_pack_type_at_cursor (PanelWidget *panel);
/* get index for insertion with pack type */
int                 panel_widget_get_new_pack_index   (PanelWidget          *panel,
						       PanelObjectPackType   pack_type);
180 181

/*needed for other panel types*/
182
gboolean	panel_widget_is_cursor		(PanelWidget *panel,
183
						 int overlap);
184 185
/* set the focus on the panel */
void            panel_widget_focus              (PanelWidget *panel);
186

187
PanelOrientation panel_widget_get_applet_orientation (PanelWidget *panel);
188

189

190 191 192 193 194 195 196 197 198 199 200 201
void     panel_widget_set_applet_size_constrained (PanelWidget *panel,
						   GtkWidget   *applet,
						   gboolean     size_constrained);
void     panel_widget_set_applet_expandable       (PanelWidget *panel,
						   GtkWidget   *applet,
						   gboolean     major,
						   gboolean     minor);
void     panel_widget_set_applet_size_hints       (PanelWidget *panel,
						   GtkWidget   *applet,
						   int         *size_hints,
						   int          size_hints_len);

202 203
void     panel_widget_register_open_dialog        (PanelWidget *panel,
						   GtkWidget   *dialog);  
204

205 206
GSList  *panel_widget_get_panels (void);

207
G_END_DECLS
208

209
#endif /* PANEL_WIDGET_H */