21
21
*/
22
22
23
23
/* Well, actuall'y is the Tray itself, the container for the items. But
24
- * NaTray is already taken for the XEMBED part, so for now it's called NaBox ,
24
+ * NaTray is already taken for the XEMBED part, so for now it's called NaGrid ,
25
25
* don't make a big deal out of it. */
26
26
27
27
#include "config.h"
28
28
29
29
#include <gtk/gtk.h>
30
30
31
- #include "na-box .h"
31
+ #include "na-grid .h"
32
32
33
33
#include "system-tray/na-tray.h"
34
34
#include "status-notifier/sn-host-v0.h"
35
35
36
36
#define ICON_SPACING 1
37
- #define MIN_BOX_SIZE 3
37
+ #define MIN_GRID_SIZE 3
38
38
39
- struct _NaBox
39
+ struct _NaGrid
40
40
{
41
41
GtkBox parent ;
42
42
54
54
PROP_ICON_SIZE
55
55
};
56
56
57
- G_DEFINE_TYPE (NaBox , na_box , GTK_TYPE_BOX )
57
+ G_DEFINE_TYPE (NaGrid , na_grid , GTK_TYPE_BOX )
58
58
59
59
static gint
60
60
compare_items (gconstpointer a ,
@@ -88,10 +88,10 @@ static void
88
88
reorder_items (GtkWidget * widget ,
89
89
gpointer user_data )
90
90
{
91
- NaBox * nb ;
91
+ NaGrid * nb ;
92
92
gint position ;
93
93
94
- nb = NA_BOX (user_data );
94
+ nb = NA_GRID (user_data );
95
95
96
96
position = g_slist_index (nb -> items , widget );
97
97
gtk_box_reorder_child (GTK_BOX (nb ), widget , position );
@@ -100,11 +100,11 @@ reorder_items (GtkWidget *widget,
100
100
static void
101
101
item_added_cb (NaHost * host ,
102
102
NaItem * item ,
103
- NaBox * self )
103
+ NaGrid * self )
104
104
{
105
105
g_return_if_fail (NA_IS_HOST (host ));
106
106
g_return_if_fail (NA_IS_ITEM (item ));
107
- g_return_if_fail (NA_IS_BOX (self ));
107
+ g_return_if_fail (NA_IS_GRID (self ));
108
108
109
109
g_object_bind_property (self , "orientation" ,
110
110
item , "orientation" ,
@@ -120,18 +120,18 @@ item_added_cb (NaHost *host,
120
120
static void
121
121
item_removed_cb (NaHost * host ,
122
122
NaItem * item ,
123
- NaBox * self )
123
+ NaGrid * self )
124
124
{
125
125
g_return_if_fail (NA_IS_HOST (host ));
126
126
g_return_if_fail (NA_IS_ITEM (item ));
127
- g_return_if_fail (NA_IS_BOX (self ));
127
+ g_return_if_fail (NA_IS_GRID (self ));
128
128
129
129
gtk_container_remove (GTK_CONTAINER (self ), GTK_WIDGET (item ));
130
130
self -> items = g_slist_remove (self -> items , item );
131
131
}
132
132
133
133
static void
134
- update_size_and_orientation (NaBox * self ,
134
+ update_size_and_orientation (NaGrid * self ,
135
135
GtkOrientation orientation )
136
136
{
137
137
/* FIXME: do we really need that? comes from NaTray */
@@ -141,11 +141,11 @@ update_size_and_orientation (NaBox *self,
141
141
switch (orientation )
142
142
{
143
143
case GTK_ORIENTATION_VERTICAL :
144
- /* Give box a min size so the frame doesn't look dumb */
145
- gtk_widget_set_size_request (GTK_WIDGET (self ), MIN_BOX_SIZE , -1 );
144
+ /* Give grid a min size so the frame doesn't look dumb */
145
+ gtk_widget_set_size_request (GTK_WIDGET (self ), MIN_GRID_SIZE , -1 );
146
146
break ;
147
147
case GTK_ORIENTATION_HORIZONTAL :
148
- gtk_widget_set_size_request (GTK_WIDGET (self ), -1 , MIN_BOX_SIZE );
148
+ gtk_widget_set_size_request (GTK_WIDGET (self ), -1 , MIN_GRID_SIZE );
149
149
break ;
150
150
}
151
151
}
@@ -155,12 +155,12 @@ orientation_notify (GObject *object,
155
155
GParamSpec * pspec ,
156
156
gpointer data )
157
157
{
158
- update_size_and_orientation (NA_BOX (object ),
158
+ update_size_and_orientation (NA_GRID (object ),
159
159
gtk_orientable_get_orientation (GTK_ORIENTABLE (object )));
160
160
}
161
161
162
162
static void
163
- na_box_init ( NaBox * self )
163
+ na_grid_init ( NaGrid * self )
164
164
{
165
165
GtkOrientation orientation ;
166
166
@@ -177,7 +177,7 @@ na_box_init (NaBox *self)
177
177
}
178
178
179
179
static void
180
- add_host (NaBox * self ,
180
+ add_host (NaGrid * self ,
181
181
NaHost * host )
182
182
{
183
183
self -> hosts = g_slist_prepend (self -> hosts , host );
@@ -194,14 +194,14 @@ add_host (NaBox *self,
194
194
}
195
195
196
196
static void
197
- na_box_style_updated (GtkWidget * widget )
197
+ na_grid_style_updated (GtkWidget * widget )
198
198
{
199
- NaBox * self = NA_BOX (widget );
199
+ NaGrid * self = NA_GRID (widget );
200
200
GtkStyleContext * context ;
201
201
GSList * node ;
202
202
203
- if (GTK_WIDGET_CLASS (na_box_parent_class )-> style_updated )
204
- GTK_WIDGET_CLASS (na_box_parent_class )-> style_updated (widget );
203
+ if (GTK_WIDGET_CLASS (na_grid_parent_class )-> style_updated )
204
+ GTK_WIDGET_CLASS (na_grid_parent_class )-> style_updated (widget );
205
205
206
206
context = gtk_widget_get_style_context (widget );
207
207
@@ -215,20 +215,20 @@ na_box_style_updated (GtkWidget *widget)
215
215
216
216
/* Custom drawing because system-tray items need weird stuff. */
217
217
static gboolean
218
- na_box_draw (GtkWidget * box ,
219
- cairo_t * cr )
218
+ na_grid_draw (GtkWidget * grid ,
219
+ cairo_t * cr )
220
220
{
221
221
GList * child ;
222
- GList * children = gtk_container_get_children (GTK_CONTAINER (box ));
222
+ GList * children = gtk_container_get_children (GTK_CONTAINER (grid ));
223
223
224
224
for (child = children ; child ; child = child -> next )
225
225
{
226
226
if (! NA_IS_ITEM (child -> data ) ||
227
- ! na_item_draw_on_parent (child -> data , box , cr ))
227
+ ! na_item_draw_on_parent (child -> data , grid , cr ))
228
228
{
229
229
if (gtk_widget_is_drawable (child -> data ) &&
230
230
gtk_cairo_should_draw_window (cr , gtk_widget_get_window (child -> data )))
231
- gtk_container_propagate_draw (GTK_CONTAINER (box ), child -> data , cr );
231
+ gtk_container_propagate_draw (GTK_CONTAINER (grid ), child -> data , cr );
232
232
}
233
233
}
234
234
@@ -238,14 +238,14 @@ na_box_draw (GtkWidget *box,
238
238
}
239
239
240
240
static void
241
- na_box_realize (GtkWidget * widget )
241
+ na_grid_realize (GtkWidget * widget )
242
242
{
243
- NaBox * self = NA_BOX (widget );
243
+ NaGrid * self = NA_GRID (widget );
244
244
GdkScreen * screen ;
245
245
GtkOrientation orientation ;
246
246
NaHost * tray_host ;
247
247
248
- GTK_WIDGET_CLASS (na_box_parent_class )-> realize (widget );
248
+ GTK_WIDGET_CLASS (na_grid_parent_class )-> realize (widget );
249
249
250
250
/* Instantiate the hosts now we have a screen */
251
251
screen = gtk_widget_get_screen (GTK_WIDGET (self ));
@@ -260,9 +260,9 @@ na_box_realize (GtkWidget *widget)
260
260
}
261
261
262
262
static void
263
- na_box_unrealize (GtkWidget * widget )
263
+ na_grid_unrealize (GtkWidget * widget )
264
264
{
265
- NaBox * self = NA_BOX (widget );
265
+ NaGrid * self = NA_GRID (widget );
266
266
267
267
if (self -> hosts != NULL )
268
268
{
@@ -272,16 +272,16 @@ na_box_unrealize (GtkWidget *widget)
272
272
273
273
g_clear_pointer (& self -> items , g_slist_free );
274
274
275
- GTK_WIDGET_CLASS (na_box_parent_class )-> unrealize (widget );
275
+ GTK_WIDGET_CLASS (na_grid_parent_class )-> unrealize (widget );
276
276
}
277
277
278
278
static void
279
- na_box_get_property (GObject * object ,
280
- guint property_id ,
281
- GValue * value ,
282
- GParamSpec * pspec )
279
+ na_grid_get_property (GObject * object ,
280
+ guint property_id ,
281
+ GValue * value ,
282
+ GParamSpec * pspec )
283
283
{
284
- NaBox * self = NA_BOX (object );
284
+ NaGrid * self = NA_GRID (object );
285
285
286
286
switch (property_id )
287
287
{
@@ -300,12 +300,12 @@ na_box_get_property (GObject *object,
300
300
}
301
301
302
302
static void
303
- na_box_set_property (GObject * object ,
304
- guint property_id ,
305
- const GValue * value ,
306
- GParamSpec * pspec )
303
+ na_grid_set_property (GObject * object ,
304
+ guint property_id ,
305
+ const GValue * value ,
306
+ GParamSpec * pspec )
307
307
{
308
- NaBox * self = NA_BOX (object );
308
+ NaGrid * self = NA_GRID (object );
309
309
310
310
switch (property_id )
311
311
{
@@ -324,18 +324,18 @@ na_box_set_property (GObject *object,
324
324
}
325
325
326
326
static void
327
- na_box_class_init ( NaBoxClass * klass )
327
+ na_grid_class_init ( NaGridClass * klass )
328
328
{
329
329
GObjectClass * gobject_class = G_OBJECT_CLASS (klass );
330
330
GtkWidgetClass * widget_class = GTK_WIDGET_CLASS (klass );
331
331
332
- gobject_class -> get_property = na_box_get_property ;
333
- gobject_class -> set_property = na_box_set_property ;
332
+ gobject_class -> get_property = na_grid_get_property ;
333
+ gobject_class -> set_property = na_grid_set_property ;
334
334
335
- widget_class -> draw = na_box_draw ;
336
- widget_class -> realize = na_box_realize ;
337
- widget_class -> unrealize = na_box_unrealize ;
338
- widget_class -> style_updated = na_box_style_updated ;
335
+ widget_class -> draw = na_grid_draw ;
336
+ widget_class -> realize = na_grid_realize ;
337
+ widget_class -> unrealize = na_grid_unrealize ;
338
+ widget_class -> style_updated = na_grid_style_updated ;
339
339
340
340
g_object_class_install_property (gobject_class , PROP_ICON_PADDING ,
341
341
g_param_spec_int ("icon-padding" ,
@@ -353,19 +353,19 @@ na_box_class_init (NaBoxClass *klass)
353
353
}
354
354
355
355
GtkWidget *
356
- na_box_new (GtkOrientation orientation )
356
+ na_grid_new (GtkOrientation orientation )
357
357
{
358
- return g_object_new (NA_TYPE_BOX ,
358
+ return g_object_new (NA_TYPE_GRID ,
359
359
"orientation" , orientation ,
360
360
"spacing" , ICON_SPACING ,
361
361
NULL );
362
362
}
363
363
364
364
void
365
- na_box_force_redraw ( NaBox * box )
365
+ na_grid_force_redraw ( NaGrid * grid )
366
366
{
367
367
GSList * node ;
368
368
369
- for (node = box -> hosts ; node ; node = node -> next )
369
+ for (node = grid -> hosts ; node ; node = node -> next )
370
370
na_host_force_redraw (node -> data );
371
371
}
0 commit comments