aboutsummaryrefslogtreecommitdiff
path: root/hildon/hildon-window-stack.c
blob: 96a34d7dd03b5d0ddca65d1a26981e4d432018df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
/*
 * This file is a part of hildon
 *
 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

/**
 * SECTION:hildon-window-stack
 * @short_description: A stack of windows in Hildon applications.
 * @see_also: #HildonStackableWindow
 *
 * The #HildonWindowStack is a stack of top-level windows.
 *
 * Stacks contain all #HildonStackableWindow<!-- -->s that are being
 * shown. The user can only interact with the topmost window from each
 * stack (as it covers all the others), but all of them are mapped and
 * visible from the Gtk point of view.
 *
 * Each window can only be in one stack at a time. All stacked windows
 * are visible and all visible windows are stacked.
 *
 * Each application has a default stack, and windows are automatically
 * added to it when they are shown with gtk_widget_show().
 *
 * Additional stacks can be created at any time using
 * hildon_window_stack_new(). To add a window to a specific stack, use
 * hildon_window_stack_push_1() (remember that, for the default stack,
 * gtk_widget_show() can be used instead).
 *
 * To remove a window from a stack use hildon_window_stack_pop_1(), or
 * simply gtk_widget_hide().
 *
 * For more complex layout changes, applications can push and/or pop
 * several windows at the same time in a single step. See
 * hildon_window_stack_push(), hildon_window_stack_pop() and
 * hildon_window_stack_pop_and_push() for more details.
 */

#include                                        "hildon-window-stack.h"
#include                                        "hildon-window-stack-private.h"
#include                                        "hildon-stackable-window-private.h"

struct                                          _HildonWindowStackPrivate
{
    GList *list;
    GtkWindowGroup *group;
    GdkWindow *leader; /* X Window group hint for all windows in a group */
};

#define                                         HILDON_WINDOW_STACK_GET_PRIVATE(obj) \
                                                (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
                                                HILDON_TYPE_WINDOW_STACK, HildonWindowStackPrivate))

G_DEFINE_TYPE (HildonWindowStack, hildon_window_stack, G_TYPE_OBJECT);

enum {
    PROP_GROUP = 1,
};

static void
hildon_window_stack_set_window_group             (HildonWindowStack *stack,
                                                  GtkWindowGroup    *group)
{
    g_return_if_fail (HILDON_IS_WINDOW_STACK (stack));
    g_return_if_fail (!group || GTK_IS_WINDOW_GROUP (group));

    /* The window group is only to be set once during construction */
    g_return_if_fail (stack->priv->group == NULL);

    if (!group)
        group = gtk_window_group_new ();

    stack->priv->group = group;
}

static GtkWindowGroup *
hildon_window_stack_get_window_group             (HildonWindowStack *stack)
{
    g_return_val_if_fail (HILDON_IS_WINDOW_STACK (stack), NULL);

    return stack->priv->group;
}

/**
 * hildon_window_stack_get_default:
 *
 * Returns the default window stack. This stack always exists and
 * doesn't need to be created by the application.
 *
 * Return value: the default #HildonWindowStack
 *
 * Since: 2.2
 **/
HildonWindowStack *
hildon_window_stack_get_default                 (void)
{
    static HildonWindowStack *stack = NULL;
    if (G_UNLIKELY (stack == NULL)) {
        stack = g_object_new (HILDON_TYPE_WINDOW_STACK,
                              "window-group", gtk_window_get_group (NULL),
                              NULL);
    }
    return stack;
}

/**
 * hildon_window_stack_new:
 *
 * Creates a new #HildonWindowStack. The stack is initially empty.
 *
 * Return value: a new #HildonWindowStack
 *
 * Since: 2.2
 **/
HildonWindowStack *
hildon_window_stack_new                         (void)
{
    HildonWindowStack *stack = g_object_new (HILDON_TYPE_WINDOW_STACK, NULL);
    return stack;
}

/**
 * hildon_window_stack_size:
 * @stack: A #HildonWindowStack
 *
 * Returns the number of windows in @stack
 *
 * Return value: Number of windows in @stack
 *
 * Since: 2.2
 **/
gint
hildon_window_stack_size                        (HildonWindowStack *stack)
{
    g_return_val_if_fail (HILDON_IS_WINDOW_STACK (stack), 0);

    return g_list_length (stack->priv->list);
}

static GdkWindow *
hildon_window_stack_get_leader_window           (HildonWindowStack *stack,
                                                 GtkWidget         *win)
{
    /* Create the X Window group (leader) if we haven't. */
    if (!stack->priv->leader) {
        if (stack == hildon_window_stack_get_default ()) {
            GdkDisplay *dpy;

            /* We're the default stack, use the default group. */
            dpy = gtk_widget_get_display (win);
            stack->priv->leader = gdk_display_get_default_group (dpy);
        } else {
            static GdkWindowAttr attr = {
                .window_type = GDK_WINDOW_TOPLEVEL,
                .x = 10, .y = 10, .width = 10, .height = 10,
                .wclass = GDK_INPUT_OUTPUT, .event_mask = 0,
            };
            GdkWindow *root;

            /* Create a new X Window group. */
            root = gtk_widget_get_root_window (win);
            stack->priv->leader = gdk_window_new (root, &attr, GDK_WA_X | GDK_WA_Y);
        }
    }

    return stack->priv->leader;
}

/* Set the X Window group of a window when it is realized. */
static void
hildon_window_stack_window_realized             (GtkWidget         *win,
                                                 HildonWindowStack *stack)
{
    GdkWindow *leader = hildon_window_stack_get_leader_window (stack, win);
    gdk_window_set_group (gtk_widget_get_window (win), leader);
}

/* Remove a window from its stack, no matter its position */
void G_GNUC_INTERNAL
hildon_window_stack_remove                      (HildonStackableWindow *win)
{
    HildonWindowStack *stack = hildon_stackable_window_get_stack (win);

    /* If the window is stacked */
    if (stack) {
        GList *pos;

        hildon_stackable_window_set_stack (win, NULL, -1);
        gtk_window_set_transient_for (GTK_WINDOW (win), NULL);
        if (gtk_widget_get_window (GTK_WIDGET (win))) {
            gdk_window_set_group (gtk_widget_get_window (GTK_WIDGET (win)), NULL);
        }

        /* If the window removed is in the middle of the stack, update
         * transiency of other windows */
        pos = g_list_find (stack->priv->list, win);
        g_assert (pos != NULL);
        if (pos->prev) {
            GtkWindow *upper = GTK_WINDOW (pos->prev->data);
            GtkWindow *lower = pos->next ? GTK_WINDOW (pos->next->data) : NULL;
            gtk_window_set_transient_for (upper, lower);
        }

        stack->priv->list = g_list_remove (stack->priv->list, win);

        g_signal_handlers_disconnect_by_func (win, hildon_window_stack_window_realized, stack);
    }
}

/**
 * hildon_window_stack_get_windows:
 * @stack: a #HildonWindowStack
 *
 * Returns the list of windows on this stack (topmost first). The
 * widgets in the list are not individually referenced. Once you are
 * done with the list you must call g_list_free().
 *
 * Returns: a newly-allocated list of #HildonStackableWindow<!-- -->s
 *
 * Since: 2.2
 **/
GList *
hildon_window_stack_get_windows                 (HildonWindowStack *stack)
{
    g_return_val_if_fail (HILDON_IS_WINDOW_STACK (stack), NULL);

    return g_list_copy (stack->priv->list);
}

/**
 * hildon_window_stack_peek:
 * @stack: A %HildonWindowStack
 *
 * Returns the window on top of @stack. The stack is never modified.
 *
 * Return value: the window on top of the stack, or %NULL if the stack
 * is empty.
 *
 * Since: 2.2
 **/
GtkWidget *
hildon_window_stack_peek                        (HildonWindowStack *stack)
{
    GtkWidget *win = NULL;

    g_return_val_if_fail (HILDON_IS_WINDOW_STACK (stack), NULL);

    if (stack->priv->list != NULL) {
        win = GTK_WIDGET (stack->priv->list->data);
    }

    return win;
}

/* This function does everything to push a window to the stack _but_
 * actually calling gtk_widget_show().
 * It's up to each specific push function to decide the order in which
 * to show windows. */
gboolean G_GNUC_INTERNAL
_hildon_window_stack_do_push                    (HildonWindowStack     *stack,
                                                 HildonStackableWindow *win)
{
    HildonWindowStack *current_stack;

    g_return_val_if_fail (HILDON_IS_WINDOW_STACK (stack), FALSE);
    g_return_val_if_fail (HILDON_IS_STACKABLE_WINDOW (win), FALSE);

    current_stack = hildon_stackable_window_get_stack (win);

    if (current_stack == NULL) {
        GtkWidget *parent = hildon_window_stack_peek (stack);
        gint pos = 0;

        if (parent) {
            pos = HILDON_STACKABLE_WINDOW_GET_PRIVATE (parent)->stack_position + 1;
        }

        /* Push the window */
        hildon_stackable_window_set_stack (win, stack, pos);
        stack->priv->list = g_list_prepend (stack->priv->list, win);

        /* Make the window part of the same group as its parent */
        if (parent) {
            gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parent));
        } else {
            gtk_window_group_add_window (stack->priv->group, GTK_WINDOW (win));
        }

        /* Set window group */
        if (gtk_widget_get_realized (GTK_WIDGET (win))) {
            hildon_window_stack_window_realized (GTK_WIDGET (win), stack);
        } else {
            g_signal_connect (win, "realize",
                              G_CALLBACK (hildon_window_stack_window_realized),
                              stack);
        }

        return TRUE;
    } else {
        g_warning ("Trying to push a window that is already on a stack");
        return FALSE;
    }
}

static GtkWidget *
_hildon_window_stack_do_pop                     (HildonWindowStack *stack)
{
    GtkWidget *win = hildon_window_stack_peek (stack);

    if (win)
        hildon_window_stack_remove (HILDON_STACKABLE_WINDOW (win));

    return win;
}

/**
 * hildon_window_stack_push_1:
 * @stack: A %HildonWindowStack
 * @win: A %HildonStackableWindow
 *
 * Adds @win to the top of @stack, and shows it. The window must not
 * be already stacked.
 *
 * Since: 2.2
 **/
void
hildon_window_stack_push_1                      (HildonWindowStack     *stack,
                                                 HildonStackableWindow *win)
{
    if (_hildon_window_stack_do_push (stack, win))
        gtk_widget_show (GTK_WIDGET (win));
}

/**
 * hildon_window_stack_pop_1:
 * @stack: A %HildonWindowStack
 *
 * Removes the window on top of @stack, and hides it. If the stack is
 * empty nothing happens.
 *
 * Return value: the window on top of the stack, or %NULL if the stack
 * is empty.
 *
 * Since: 2.2
 **/
GtkWidget *
hildon_window_stack_pop_1                       (HildonWindowStack *stack)
{
    GtkWidget *win = _hildon_window_stack_do_pop (stack);
    if (win)
        gtk_widget_hide (win);
    return win;
}

/**
 * hildon_window_stack_push_list:
 * @stack: A %HildonWindowStack
 * @list: A list of %HildonStackableWindow<!-- -->s to push
 *
 * Pushes all windows in @list to the top of @stack, and shows
 * them. Everything is done in a single transition, so the user will
 * only see the last window in @list during this operation. None of
 * the windows must be already stacked.
 *
 * Since: 2.2
 **/
void
hildon_window_stack_push_list                   (HildonWindowStack *stack,
                                                 GList             *list)
{
    HildonStackableWindow *win;
    GList *l;
    GList *pushed = NULL;

    g_return_if_fail (HILDON_IS_WINDOW_STACK (stack));

    /* Stack all windows */
    for (l = list; l != NULL; l = g_list_next (l)) {
        win = HILDON_STACKABLE_WINDOW (l->data);
        if (win) {
            _hildon_window_stack_do_push (stack, win);
            pushed = g_list_prepend (pushed, win);
        } else {
            g_warning ("Trying to stack a non-stackable window!");
        }
    }

    /* Show windows in reverse order (topmost first) */
    g_list_foreach (pushed, (GFunc) gtk_widget_show, NULL);

    g_list_free (pushed);
}

/**
 * hildon_window_stack_push:
 * @stack: A %HildonWindowStack
 * @win1: The first window to push
 * @Varargs: A %NULL-terminated list of additional #HildonStackableWindow<!-- -->s to push.
 *
 * Pushes all windows to the top of @stack, and shows them. Everything
 * is done in a single transition, so the user will only see the last
 * window. None of the windows must be already stacked.
 *
 * Since: 2.2
 **/
void
hildon_window_stack_push                        (HildonWindowStack     *stack,
                                                 HildonStackableWindow *win1,
                                                 ...)
{
    HildonStackableWindow *win = win1;
    GList *list = NULL;
    va_list args;

    va_start (args, win1);

    while (win != NULL) {
        list = g_list_prepend (list, win);
        win = va_arg (args, HildonStackableWindow *);
    }

    va_end (args);

    list = g_list_reverse (list);

    hildon_window_stack_push_list (stack, list);
    g_list_free (list);
}

/**
 * hildon_window_stack_pop:
 * @stack: A %HildonWindowStack
 * @nwindows: Number of windows to pop
 * @popped_windows: if non-%NULL, the list of popped windows is stored here
 *
 * Pops @nwindows windows from @stack, and hides them. Everything is
 * done in a single transition, so the user will not see any of the
 * windows being popped in this operation.
 *
 * If @popped_windows is not %NULL, the list of popped windows is
 * stored there (ordered bottom-up). That list must be freed by the
 * user.
 *
 * Since: 2.2
 **/
void
hildon_window_stack_pop                         (HildonWindowStack  *stack,
                                                 gint                nwindows,
                                                 GList             **popped_windows)
{
    gint i;
    GList *popped = NULL;

    g_return_if_fail (HILDON_IS_WINDOW_STACK (stack));
    g_return_if_fail (nwindows > 0);
    g_return_if_fail (g_list_length (stack->priv->list) >= nwindows);

    /* Pop windows */
    for (i = 0; i < nwindows; i++) {
        GtkWidget *win = _hildon_window_stack_do_pop (stack);
        popped = g_list_prepend (popped, win);
    }

    /* Hide windows in reverse order (topmost last) */
    g_list_foreach (popped, (GFunc) gtk_widget_hide, NULL);

    if (popped_windows) {
        *popped_windows = popped;
    } else {
        g_list_free (popped);
    }
}

/**
 * hildon_window_stack_pop_and_push_list:
 * @stack: A %HildonWindowStack
 * @nwindows: Number of windows to pop.
 * @popped_windows: if non-%NULL, the list of popped windows is stored here
 * @list: A list of %HildonStackableWindow<!-- -->s to push
 *
 * Pops @nwindows windows from @stack (and hides them), then pushes
 * all windows in @list (and shows them). Everything is done in a
 * single transition, so the user will only see the last window from
 * @list. None of the pushed windows must be already stacked.
 *
 * If @popped_windows is not %NULL, the list of popped windows is
 * stored there (ordered bottom-up). That list must be freed by the
 * user.
 *
 * Since: 2.2
 **/
void
hildon_window_stack_pop_and_push_list           (HildonWindowStack  *stack,
                                                 gint                nwindows,
                                                 GList             **popped_windows,
                                                 GList              *list)
{
    gint i, topmost_index;
    GList *l;
    GList *popped = NULL;
    GList *pushed = NULL;
    HildonStackableWindowPrivate *priv;

    g_return_if_fail (HILDON_IS_WINDOW_STACK (stack));
    g_return_if_fail (nwindows > 0);
    g_return_if_fail (g_list_length (stack->priv->list) >= nwindows);

    /*
     * We need to call gdk_flush() because the application that called us might
     * just shown some of the windows we manipulate, and if the GTK+ has not
     * processed the MapNotify yet it will end up calling the XWithdrawWindow
     * when we hide the window (and will actually not unmap it).
     */
    gdk_flush ();

    /* Store the index of the topmost window */
    priv = HILDON_STACKABLE_WINDOW_GET_PRIVATE (hildon_window_stack_peek (stack));
    topmost_index = priv->stack_position;

    /* Pop windows */
    for (i = 0; i < nwindows; i++) {
        GtkWidget *win = _hildon_window_stack_do_pop (stack);
        popped = g_list_prepend (popped, win);
        /* Hide now windows that are popped and then pushed back.
           This way all the windows that has a changed stack index
           will be unmapped and mapped again. */
        if (g_list_find (list, win) != NULL) {
            gtk_widget_hide (win);
        }
    }

    /* Push windows */
    for (l = list; l != NULL; l = g_list_next (l)) {
        HildonStackableWindow *win = HILDON_STACKABLE_WINDOW (l->data);
        if (win) {
            _hildon_window_stack_do_push (stack, win);
            pushed = g_list_prepend (pushed, win);
        } else {
            g_warning ("Trying to stack a non-stackable window!");
        }
    }

    if (pushed != NULL) {
        /* The WM will be confused if the old topmost window and the new
         * one have the same index, so make sure that they're different */
        priv = HILDON_STACKABLE_WINDOW_GET_PRIVATE (hildon_window_stack_peek (stack));
        if (priv->stack_position == topmost_index) {
            priv->stack_position++;
        }
    }

    /* Show windows in reverse order (topmost first) */
    g_list_foreach (pushed, (GFunc) gtk_widget_show, NULL);

    /* Hide windows that are popped but not pushed back (topmost last) */
    for (l = popped; l != NULL; l = l->next) {
        if (g_list_find (list, l->data) == NULL) {
            gtk_widget_hide (GTK_WIDGET (l->data));
        }
    }

    g_list_free (pushed);
    if (popped_windows) {
        *popped_windows = popped;
    } else {
        g_list_free (popped);
    }
}

/**
 * hildon_window_stack_pop_and_push:
 * @stack: A %HildonWindowStack
 * @nwindows: Number of windows to pop.
 * @popped_windows: if non-%NULL, the list of popped windows is stored here
 * @win1: The first window to push
 * @Varargs: A %NULL-terminated list of additional #HildonStackableWindow<!-- -->s to push.
 *
 * Pops @nwindows windows from @stack (and hides them), then pushes
 * all passed windows (and shows them). Everything is done in a single
 * transition, so the user will only see the last pushed window. None
 * of the pushed windows must be already stacked.
 *
 * If @popped_windows is not %NULL, the list of popped windows is
 * stored there (ordered bottom-up). That list must be freed by the
 * user.
 *
 * Since: 2.2
 **/
void
hildon_window_stack_pop_and_push                (HildonWindowStack      *stack,
                                                 gint                    nwindows,
                                                 GList                 **popped_windows,
                                                 HildonStackableWindow  *win1,
                                                 ...)
{
    HildonStackableWindow *win = win1;
    GList *list = NULL;
    va_list args;

    va_start (args, win1);

    while (win != NULL) {
        list = g_list_prepend (list, win);
        win = va_arg (args, HildonStackableWindow *);
    }

    va_end (args);

    list = g_list_reverse (list);

    hildon_window_stack_pop_and_push_list (stack, nwindows, popped_windows, list);
    g_list_free (list);
}

static void
hildon_window_stack_finalize (GObject *object)
{
    HildonWindowStack *stack = HILDON_WINDOW_STACK (object);

    if (stack->priv->list)
        hildon_window_stack_pop (stack, hildon_window_stack_size (stack), NULL);

    if (stack->priv->group)
        g_object_unref (stack->priv->group);

    /* Since the default group stack shouldn't be finalized,
     * it's safe to destroy the X Window group we created. */
    if (stack->priv->leader)
        gdk_window_destroy (stack->priv->leader);

    G_OBJECT_CLASS (hildon_window_stack_parent_class)->finalize (object);
}

static void
hildon_window_stack_set_property                (GObject      *object,
                                                 guint         prop_id,
                                                 const GValue *value,
                                                 GParamSpec   *pspec)
{
    HildonWindowStack *stack = HILDON_WINDOW_STACK (object);

    switch (prop_id)
    {
    case PROP_GROUP:
        hildon_window_stack_set_window_group (stack, g_value_get_object (value));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}

static void
hildon_window_stack_get_property                (GObject    *object,
                                                 guint       prop_id,
                                                 GValue     *value,
                                                 GParamSpec *pspec)
{
    HildonWindowStack *stack = HILDON_WINDOW_STACK (object);

    switch (prop_id)
    {
    case PROP_GROUP:
        g_value_set_object (value, hildon_window_stack_get_window_group (stack));
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}

static void
hildon_window_stack_class_init (HildonWindowStackClass *klass)
{
    GObjectClass *gobject_class = (GObjectClass *)klass;

    gobject_class->set_property = hildon_window_stack_set_property;
    gobject_class->get_property = hildon_window_stack_get_property;
    gobject_class->finalize = hildon_window_stack_finalize;

    g_object_class_install_property (
        gobject_class,
        PROP_GROUP,
        g_param_spec_object (
            "window-group",
            "GtkWindowGroup for this stack",
            "GtkWindowGroup that all windows on this stack belong to",
            GTK_TYPE_WINDOW_GROUP,
            G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));

    g_type_class_add_private (klass, sizeof (HildonWindowStackPrivate));
}

static void
hildon_window_stack_init (HildonWindowStack *self)
{
    HildonWindowStackPrivate *priv;

    priv = self->priv = HILDON_WINDOW_STACK_GET_PRIVATE (self);

    priv->list = NULL;
    priv->group = NULL;
}