Skip to content

Commit 9bdd469

Browse files
braikarlukefromdc
authored andcommitted
na-tray: wide panels, preliminary batch box to grid rename
box/Box/BOX changed to grid/Grid/GRID as a preliminary step to prepare for changing GtkBox in na-box/na-grid to a GtkGrid to make the notification area work well on vertical and wide panels note: even if everything is renamed to grid, the GtkWidget is still a GtkBox thats why GtkBox and GTK_TYPE_BOX have not been renamed.
1 parent 3f351d5 commit 9bdd469

File tree

5 files changed

+78
-91
lines changed

5 files changed

+78
-91
lines changed

applets/notification_area/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ AM_CPPFLAGS = \
2020
AM_CFLAGS = $(WARN_CFLAGS)
2121

2222
libtray_la_SOURCES = \
23-
na-box.c \
24-
na-box.h \
23+
na-grid.c \
24+
na-grid.h \
2525
na-host.c \
2626
na-host.h \
2727
na-item.c \

applets/notification_area/main.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <gtk/gtk.h>
3131

3232
#include "main.h"
33-
#include "na-box.h"
33+
#include "na-grid.h"
3434

3535
#ifdef PROVIDE_WATCHER_SERVICE
3636
# include "libstatus-notifier-watcher/gf-status-notifier-watcher.h"
@@ -40,7 +40,7 @@
4040

4141
struct _NaTrayAppletPrivate
4242
{
43-
GtkWidget *box;
43+
GtkWidget *grid;
4444

4545
#ifdef PROVIDE_WATCHER_SERVICE
4646
GfStatusNotifierWatcher *sn_watcher;
@@ -225,14 +225,14 @@ na_tray_applet_style_updated (GtkWidget *widget)
225225
if (parent_class_style_updated)
226226
parent_class_style_updated (widget);
227227

228-
if (!applet->priv->box)
228+
if (!applet->priv->grid)
229229
return;
230230

231231
gtk_widget_style_get (widget,
232232
"icon-padding", &padding,
233233
"icon-size", &icon_size,
234234
NULL);
235-
g_object_set (applet->priv->box,
235+
g_object_set (applet->priv->grid,
236236
"icon-padding", padding,
237237
"icon-size", icon_size,
238238
NULL);
@@ -247,8 +247,8 @@ na_tray_applet_change_background(MatePanelApplet* panel_applet, MatePanelAppletB
247247
parent_class_change_background (panel_applet, type, color, pattern);
248248
}
249249

250-
if (applet->priv->box)
251-
na_box_force_redraw (NA_BOX (applet->priv->box));
250+
if (applet->priv->grid)
251+
na_grid_force_redraw (NA_GRID (applet->priv->grid));
252252
}
253253

254254
static void
@@ -260,10 +260,10 @@ na_tray_applet_change_orient (MatePanelApplet *panel_applet,
260260
if (parent_class_change_orient)
261261
parent_class_change_orient (panel_applet, orient);
262262

263-
if (!applet->priv->box)
263+
if (!applet->priv->grid)
264264
return;
265265

266-
gtk_orientable_set_orientation (GTK_ORIENTABLE (applet->priv->box),
266+
gtk_orientable_set_orientation (GTK_ORIENTABLE (applet->priv->grid),
267267
get_gtk_orientation_from_applet_orient (orient));
268268
}
269269

@@ -286,10 +286,10 @@ na_tray_applet_focus (GtkWidget *widget,
286286
{
287287
NaTrayApplet *applet = NA_TRAY_APPLET (widget);
288288

289-
/* We let the box handle the focus movement because we behave more like a
289+
/* We let the grid handle the focus movement because we behave more like a
290290
* container than a single applet. But if focus didn't move, we let the
291291
* applet do its thing. */
292-
if (gtk_widget_child_focus (applet->priv->box, direction))
292+
if (gtk_widget_child_focus (applet->priv->grid, direction))
293293
return TRUE;
294294

295295
return GTK_WIDGET_CLASS (na_tray_applet_parent_class)->focus (widget, direction);
@@ -353,10 +353,10 @@ na_tray_applet_init (NaTrayApplet *applet)
353353
#endif
354354

355355
orient = mate_panel_applet_get_orient (MATE_PANEL_APPLET (applet));
356-
applet->priv->box = na_box_new (get_gtk_orientation_from_applet_orient (orient));
356+
applet->priv->grid = na_grid_new (get_gtk_orientation_from_applet_orient (orient));
357357

358-
gtk_container_add (GTK_CONTAINER (applet), GTK_WIDGET (applet->priv->box));
359-
gtk_widget_show (GTK_WIDGET (applet->priv->box));
358+
gtk_container_add (GTK_CONTAINER (applet), GTK_WIDGET (applet->priv->grid));
359+
gtk_widget_show (GTK_WIDGET (applet->priv->grid));
360360

361361
atko = gtk_widget_get_accessible (GTK_WIDGET (applet));
362362
atk_object_set_name (atko, _("Panel Notification Area"));

applets/notification_area/na-box.c renamed to applets/notification_area/na-grid.c

+54-54
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
*/
2222

2323
/* 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,
2525
* don't make a big deal out of it. */
2626

2727
#include "config.h"
2828

2929
#include <gtk/gtk.h>
3030

31-
#include "na-box.h"
31+
#include "na-grid.h"
3232

3333
#include "system-tray/na-tray.h"
3434
#include "status-notifier/sn-host-v0.h"
3535

3636
#define ICON_SPACING 1
37-
#define MIN_BOX_SIZE 3
37+
#define MIN_GRID_SIZE 3
3838

39-
struct _NaBox
39+
struct _NaGrid
4040
{
4141
GtkBox parent;
4242

@@ -54,7 +54,7 @@ enum
5454
PROP_ICON_SIZE
5555
};
5656

57-
G_DEFINE_TYPE (NaBox, na_box, GTK_TYPE_BOX)
57+
G_DEFINE_TYPE (NaGrid, na_grid, GTK_TYPE_BOX)
5858

5959
static gint
6060
compare_items (gconstpointer a,
@@ -88,10 +88,10 @@ static void
8888
reorder_items (GtkWidget *widget,
8989
gpointer user_data)
9090
{
91-
NaBox *nb;
91+
NaGrid *nb;
9292
gint position;
9393

94-
nb = NA_BOX (user_data);
94+
nb = NA_GRID (user_data);
9595

9696
position = g_slist_index (nb->items, widget);
9797
gtk_box_reorder_child (GTK_BOX (nb), widget, position);
@@ -100,11 +100,11 @@ reorder_items (GtkWidget *widget,
100100
static void
101101
item_added_cb (NaHost *host,
102102
NaItem *item,
103-
NaBox *self)
103+
NaGrid *self)
104104
{
105105
g_return_if_fail (NA_IS_HOST (host));
106106
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));
108108

109109
g_object_bind_property (self, "orientation",
110110
item, "orientation",
@@ -120,18 +120,18 @@ item_added_cb (NaHost *host,
120120
static void
121121
item_removed_cb (NaHost *host,
122122
NaItem *item,
123-
NaBox *self)
123+
NaGrid *self)
124124
{
125125
g_return_if_fail (NA_IS_HOST (host));
126126
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));
128128

129129
gtk_container_remove (GTK_CONTAINER (self), GTK_WIDGET (item));
130130
self->items = g_slist_remove (self->items, item);
131131
}
132132

133133
static void
134-
update_size_and_orientation (NaBox *self,
134+
update_size_and_orientation (NaGrid *self,
135135
GtkOrientation orientation)
136136
{
137137
/* FIXME: do we really need that? comes from NaTray */
@@ -141,11 +141,11 @@ update_size_and_orientation (NaBox *self,
141141
switch (orientation)
142142
{
143143
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);
146146
break;
147147
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);
149149
break;
150150
}
151151
}
@@ -155,12 +155,12 @@ orientation_notify (GObject *object,
155155
GParamSpec *pspec,
156156
gpointer data)
157157
{
158-
update_size_and_orientation (NA_BOX (object),
158+
update_size_and_orientation (NA_GRID (object),
159159
gtk_orientable_get_orientation (GTK_ORIENTABLE (object)));
160160
}
161161

162162
static void
163-
na_box_init (NaBox *self)
163+
na_grid_init (NaGrid *self)
164164
{
165165
GtkOrientation orientation;
166166

@@ -177,7 +177,7 @@ na_box_init (NaBox *self)
177177
}
178178

179179
static void
180-
add_host (NaBox *self,
180+
add_host (NaGrid *self,
181181
NaHost *host)
182182
{
183183
self->hosts = g_slist_prepend (self->hosts, host);
@@ -194,14 +194,14 @@ add_host (NaBox *self,
194194
}
195195

196196
static void
197-
na_box_style_updated (GtkWidget *widget)
197+
na_grid_style_updated (GtkWidget *widget)
198198
{
199-
NaBox *self = NA_BOX (widget);
199+
NaGrid *self = NA_GRID (widget);
200200
GtkStyleContext *context;
201201
GSList *node;
202202

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);
205205

206206
context = gtk_widget_get_style_context (widget);
207207

@@ -215,20 +215,20 @@ na_box_style_updated (GtkWidget *widget)
215215

216216
/* Custom drawing because system-tray items need weird stuff. */
217217
static gboolean
218-
na_box_draw (GtkWidget *box,
219-
cairo_t *cr)
218+
na_grid_draw (GtkWidget *grid,
219+
cairo_t *cr)
220220
{
221221
GList *child;
222-
GList *children = gtk_container_get_children (GTK_CONTAINER (box));
222+
GList *children = gtk_container_get_children (GTK_CONTAINER (grid));
223223

224224
for (child = children; child; child = child->next)
225225
{
226226
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))
228228
{
229229
if (gtk_widget_is_drawable (child->data) &&
230230
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);
232232
}
233233
}
234234

@@ -238,14 +238,14 @@ na_box_draw (GtkWidget *box,
238238
}
239239

240240
static void
241-
na_box_realize (GtkWidget *widget)
241+
na_grid_realize (GtkWidget *widget)
242242
{
243-
NaBox *self = NA_BOX (widget);
243+
NaGrid *self = NA_GRID (widget);
244244
GdkScreen *screen;
245245
GtkOrientation orientation;
246246
NaHost *tray_host;
247247

248-
GTK_WIDGET_CLASS (na_box_parent_class)->realize (widget);
248+
GTK_WIDGET_CLASS (na_grid_parent_class)->realize (widget);
249249

250250
/* Instantiate the hosts now we have a screen */
251251
screen = gtk_widget_get_screen (GTK_WIDGET (self));
@@ -260,9 +260,9 @@ na_box_realize (GtkWidget *widget)
260260
}
261261

262262
static void
263-
na_box_unrealize (GtkWidget *widget)
263+
na_grid_unrealize (GtkWidget *widget)
264264
{
265-
NaBox *self = NA_BOX (widget);
265+
NaGrid *self = NA_GRID (widget);
266266

267267
if (self->hosts != NULL)
268268
{
@@ -272,16 +272,16 @@ na_box_unrealize (GtkWidget *widget)
272272

273273
g_clear_pointer (&self->items, g_slist_free);
274274

275-
GTK_WIDGET_CLASS (na_box_parent_class)->unrealize (widget);
275+
GTK_WIDGET_CLASS (na_grid_parent_class)->unrealize (widget);
276276
}
277277

278278
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)
283283
{
284-
NaBox *self = NA_BOX (object);
284+
NaGrid *self = NA_GRID (object);
285285

286286
switch (property_id)
287287
{
@@ -300,12 +300,12 @@ na_box_get_property (GObject *object,
300300
}
301301

302302
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)
307307
{
308-
NaBox *self = NA_BOX (object);
308+
NaGrid *self = NA_GRID (object);
309309

310310
switch (property_id)
311311
{
@@ -324,18 +324,18 @@ na_box_set_property (GObject *object,
324324
}
325325

326326
static void
327-
na_box_class_init (NaBoxClass *klass)
327+
na_grid_class_init (NaGridClass *klass)
328328
{
329329
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
330330
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
331331

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;
334334

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;
339339

340340
g_object_class_install_property (gobject_class, PROP_ICON_PADDING,
341341
g_param_spec_int ("icon-padding",
@@ -353,19 +353,19 @@ na_box_class_init (NaBoxClass *klass)
353353
}
354354

355355
GtkWidget *
356-
na_box_new (GtkOrientation orientation)
356+
na_grid_new (GtkOrientation orientation)
357357
{
358-
return g_object_new (NA_TYPE_BOX,
358+
return g_object_new (NA_TYPE_GRID,
359359
"orientation", orientation,
360360
"spacing", ICON_SPACING,
361361
NULL);
362362
}
363363

364364
void
365-
na_box_force_redraw (NaBox *box)
365+
na_grid_force_redraw (NaGrid *grid)
366366
{
367367
GSList *node;
368368

369-
for (node = box->hosts; node; node = node->next)
369+
for (node = grid->hosts; node; node = node->next)
370370
na_host_force_redraw (node->data);
371371
}

0 commit comments

Comments
 (0)