1 | /* Gnome panel: panel widget |
---|
2 | * (C) 1997-1998 the Free Software Foundation |
---|
3 | * |
---|
4 | * Authors: George Lebl |
---|
5 | */ |
---|
6 | /* This widget, although slightly written as a general purpose widget, it |
---|
7 | has MANY interdependencies, which makes it almost impossible to use in |
---|
8 | anything else but the panel, what it would need is some serious |
---|
9 | cleaning up*/ |
---|
10 | #ifndef PANEL_WIDGET_H |
---|
11 | #define PANEL_WIDGET_H |
---|
12 | |
---|
13 | |
---|
14 | #include <gtk/gtk.h> |
---|
15 | #include <gdk-pixbuf/gdk-pixbuf.h> |
---|
16 | #include "button-widget.h" |
---|
17 | #include "panel-types.h" |
---|
18 | #include "panel-background.h" |
---|
19 | |
---|
20 | G_BEGIN_DECLS |
---|
21 | |
---|
22 | #define PANEL_TYPE_WIDGET (panel_widget_get_type ()) |
---|
23 | #define PANEL_WIDGET(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANEL_TYPE_WIDGET, PanelWidget)) |
---|
24 | #define PANEL_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANEL_TYPE_WIDGET, PanelWidgetClass)) |
---|
25 | #define PANEL_IS_WIDGET(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANEL_TYPE_WIDGET)) |
---|
26 | |
---|
27 | #define PANEL_MINIMUM_WIDTH 12 |
---|
28 | |
---|
29 | #define PANEL_APPLET_ASSOC_PANEL_KEY "panel_applet_assoc_panel_key" |
---|
30 | #define PANEL_APPLET_FORBIDDEN_PANELS "panel_applet_forbidden_panels" |
---|
31 | #define PANEL_APPLET_DATA "panel_applet_data" |
---|
32 | |
---|
33 | typedef struct _PanelWidget PanelWidget; |
---|
34 | typedef struct _PanelWidgetClass PanelWidgetClass; |
---|
35 | |
---|
36 | typedef struct _AppletRecord AppletRecord; |
---|
37 | typedef struct _AppletData AppletData; |
---|
38 | typedef struct _DNDRecord DNDRecord; |
---|
39 | |
---|
40 | struct _AppletData |
---|
41 | { |
---|
42 | GtkWidget * applet; |
---|
43 | int pos; |
---|
44 | int cells; |
---|
45 | int min_cells; |
---|
46 | |
---|
47 | gboolean expand_major; |
---|
48 | gboolean expand_minor; |
---|
49 | |
---|
50 | gboolean dirty; |
---|
51 | |
---|
52 | int drag_off; /* offset on the applet where drag |
---|
53 | was started */ |
---|
54 | |
---|
55 | int no_die; /* if >0 never send the about to die |
---|
56 | signal, an int and not a bool for |
---|
57 | nesting reasons */ |
---|
58 | |
---|
59 | /* Valid size ranges for expanded applets */ |
---|
60 | int * size_hints; |
---|
61 | int size_hints_len; |
---|
62 | |
---|
63 | }; |
---|
64 | |
---|
65 | struct _PanelWidget |
---|
66 | { |
---|
67 | GtkFixed fixed; |
---|
68 | |
---|
69 | gchar *unique_id; |
---|
70 | |
---|
71 | GList *applet_list; |
---|
72 | |
---|
73 | int size; |
---|
74 | GtkOrientation orient; |
---|
75 | int sz; |
---|
76 | |
---|
77 | AppletData *currently_dragged_applet; |
---|
78 | |
---|
79 | int thick; |
---|
80 | |
---|
81 | PanelBackground background; |
---|
82 | |
---|
83 | GtkWidget *master_widget; |
---|
84 | |
---|
85 | GtkWidget *drop_widget; /* widget that the panel checks for |
---|
86 | * the cursor on drops usually the |
---|
87 | * panel widget itself |
---|
88 | */ |
---|
89 | |
---|
90 | GtkWidget *panel_parent; |
---|
91 | |
---|
92 | GdkEventKey *key_event; |
---|
93 | |
---|
94 | guint packed : 1; |
---|
95 | |
---|
96 | guint inhibit_draw : 1; |
---|
97 | }; |
---|
98 | |
---|
99 | struct _PanelWidgetClass |
---|
100 | { |
---|
101 | GtkFixedClass parent_class; |
---|
102 | |
---|
103 | void (* orient_change) (PanelWidget *panel); |
---|
104 | void (* size_change) (PanelWidget *panel); |
---|
105 | void (* applet_move) (PanelWidget *panel, |
---|
106 | GtkWidget *applet); |
---|
107 | void (* applet_added) (PanelWidget *panel, |
---|
108 | GtkWidget *applet); |
---|
109 | void (* applet_removed) (PanelWidget *panel, |
---|
110 | GtkWidget *applet); |
---|
111 | void (* back_change) (PanelWidget *panel); |
---|
112 | void (* push_move) (PanelWidget *panel, |
---|
113 | GtkDirectionType dir); |
---|
114 | void (* switch_move) (PanelWidget *panel, |
---|
115 | GtkDirectionType dir); |
---|
116 | void (* free_move) (PanelWidget *panel, |
---|
117 | GtkDirectionType dir); |
---|
118 | void (* tab_move) (PanelWidget *panel, |
---|
119 | gboolean next); |
---|
120 | void (* end_move) (PanelWidget *panel); |
---|
121 | }; |
---|
122 | |
---|
123 | GType panel_widget_get_type (void) G_GNUC_CONST; |
---|
124 | |
---|
125 | GtkWidget * panel_widget_new (const char *panel_id, |
---|
126 | gboolean packed, |
---|
127 | GtkOrientation orient, |
---|
128 | int sz, |
---|
129 | PanelBackgroundType back_type, |
---|
130 | const char *back_pixmap, |
---|
131 | gboolean fit_pixmap_bg, |
---|
132 | gboolean stretch_pixmap_bg, |
---|
133 | gboolean rotate_pixmap_bg, |
---|
134 | PanelColor *back_color); |
---|
135 | /*add an applet to the panel, preferably at position pos, if insert_at_pos |
---|
136 | is on, we REALLY want to insert at the pos given by pos*/ |
---|
137 | int panel_widget_add (PanelWidget *panel, |
---|
138 | GtkWidget *applet, |
---|
139 | int pos, |
---|
140 | gboolean insert_at_pos, |
---|
141 | gboolean expand_major, |
---|
142 | gboolean expand_minor); |
---|
143 | |
---|
144 | PanelWidget * panel_widget_get_by_id (gchar *id); |
---|
145 | void panel_widget_set_id (PanelWidget *panel, |
---|
146 | const char *id); |
---|
147 | void panel_widget_set_new_id (PanelWidget *panel); |
---|
148 | |
---|
149 | /*needs to be called for drawers after add*/ |
---|
150 | void panel_widget_add_forbidden (PanelWidget *panel); |
---|
151 | |
---|
152 | /*move applet to a different panel*/ |
---|
153 | int panel_widget_reparent (PanelWidget *old_panel, |
---|
154 | PanelWidget *new_panel, |
---|
155 | GtkWidget *applet, |
---|
156 | int pos); |
---|
157 | |
---|
158 | /* use these for drag_off for special cases */ |
---|
159 | #define PW_DRAG_OFF_CURSOR -1 |
---|
160 | #define PW_DRAG_OFF_CENTER -2 |
---|
161 | |
---|
162 | /*drag*/ |
---|
163 | void panel_widget_applet_drag_start (PanelWidget *panel, |
---|
164 | GtkWidget *applet, |
---|
165 | int drag_off); |
---|
166 | void panel_widget_applet_drag_end (PanelWidget *panel); |
---|
167 | |
---|
168 | /* needed for corba */ |
---|
169 | void panel_widget_applet_drag_start_no_grab(PanelWidget *panel, |
---|
170 | GtkWidget *applet, |
---|
171 | int drag_off); |
---|
172 | void panel_widget_applet_drag_end_no_grab(PanelWidget *panel); |
---|
173 | |
---|
174 | /* changing parameters */ |
---|
175 | void panel_widget_change_params (PanelWidget *panel, |
---|
176 | GtkOrientation orient, |
---|
177 | int sz, |
---|
178 | PanelBackgroundType back_type, |
---|
179 | const char *pixmap_name, |
---|
180 | gboolean fit_pixmap_bg, |
---|
181 | gboolean stretch_pixmap_bg, |
---|
182 | gboolean rotate_pixmap_bg, |
---|
183 | PanelColor *back_color); |
---|
184 | |
---|
185 | void panel_widget_set_back_pixmap (PanelWidget *panel, |
---|
186 | const char *file); |
---|
187 | void panel_widget_set_back_color (PanelWidget *panel, |
---|
188 | PanelColor *color); |
---|
189 | |
---|
190 | /*draw EVERYTHING (meaning icons)*/ |
---|
191 | void panel_widget_draw_all (PanelWidget *panel, |
---|
192 | GdkRectangle *area); |
---|
193 | /*draw just one icon (applet has to be an icon of course)*/ |
---|
194 | void panel_widget_draw_icon (PanelWidget *panel, |
---|
195 | ButtonWidget *applet); |
---|
196 | |
---|
197 | |
---|
198 | /*tells us if an applet is "stuck" on the right side*/ |
---|
199 | int panel_widget_is_applet_stuck (PanelWidget *panel, |
---|
200 | GtkWidget *applet); |
---|
201 | /*get pos of the cursor location*/ |
---|
202 | int panel_widget_get_cursorloc (PanelWidget *panel); |
---|
203 | |
---|
204 | /*needed for other panel types*/ |
---|
205 | gboolean panel_widget_is_cursor (PanelWidget *panel, |
---|
206 | int overlap); |
---|
207 | /* set the focus on the panel */ |
---|
208 | void panel_widget_focus (PanelWidget *panel); |
---|
209 | |
---|
210 | PanelOrient panel_widget_get_applet_orient (PanelWidget *panel); |
---|
211 | |
---|
212 | extern gboolean panel_applet_in_drag; |
---|
213 | |
---|
214 | G_END_DECLS |
---|
215 | |
---|
216 | #endif /* PANEL_WIDGET_H */ |
---|