summaryrefslogtreecommitdiffstats
path: root/widgets/src/glade-adaptor.c
blob: 871e21c1cca4626d63577e79bf2fd4fe512673a5 (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
/*
 * Copyright (C) 2011  Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Author: Chris Lumens <clumens@redhat.com>
 */

/* This file contains code called by glade when it creates, reads, writes, or
 * otherwise manipulates anaconda-specific widgets.  Each function in this file
 * that glade should call must be referenced in a glade-widget-class stanza of
 * glade/AnacondaWidgets.xml.
 *
 * This file relies on a lot of halfway documented magic.  Good luck.
 */
#include <gladeui/glade-project.h>
#include <gladeui/glade-widget.h>
#include <gladeui/glade-widget-adaptor.h>

#include <gtk/gtk.h>

#include "BaseWindow.h"
#include "HubWindow.h"
#include "SpokeWindow.h"

void anaconda_standalone_window_post_create(GladeWidgetAdaptor *adaptor,
                                            GObject *object, GladeCreateReason reason) {
    GladeWidget *widget, *action_area_widget, *nav_area_widget, *alignment_widget;
    AnacondaBaseWindow *window;

    g_return_if_fail(ANACONDA_IS_BASE_WINDOW(object));

    widget = glade_widget_get_from_gobject(GTK_WIDGET(object));
    if (!widget)
        return;

    /* Set these properties both on creating a new widget and on loading a
     * widget from an existing file.  Too bad I have to duplicate this information
     * from the widget source files, but glade has no way of figuring it out
     * otherwise.
     */
    window = ANACONDA_BASE_WINDOW(object);
    action_area_widget = glade_widget_get_from_gobject(anaconda_base_window_get_action_area(window));
    glade_widget_property_set(action_area_widget, "size", 1);

    nav_area_widget = glade_widget_get_from_gobject(anaconda_base_window_get_nav_area(window));
    glade_widget_property_set(nav_area_widget, "n-rows", 2);
    glade_widget_property_set(nav_area_widget, "n-columns", 2);

    alignment_widget = glade_widget_get_from_gobject(anaconda_base_window_get_alignment(window));

    if (ANACONDA_IS_HUB_WINDOW(object)) {
        glade_widget_property_set(alignment_widget, "xalign", 0.5);
        glade_widget_property_set(alignment_widget, "yalign", 0.0);
        glade_widget_property_set(alignment_widget, "xscale", 0.5);
        glade_widget_property_set(alignment_widget, "yscale", 0.5);
    } else {
        glade_widget_property_set(alignment_widget, "xalign", 0.5);
        glade_widget_property_set(alignment_widget, "yalign", 0.0);
        glade_widget_property_set(alignment_widget, "xscale", 0.0);
        glade_widget_property_set(alignment_widget, "yscale", 0.5);
    }
}

void anaconda_standalone_window_write_widget(GladeWidgetAdaptor *adaptor,
                                             GladeWidget *widget,
                                             GladeXmlContext *context, GladeXmlNode *node) {
    GladeProperty *startup_id_prop;

    if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
        return;

    /* Set a bogus startup-id in the output XML file.  This doesn't really seem
     * like it should be necessary, but glade will crash if I don't.
     */
    startup_id_prop = glade_widget_get_property(widget, "startup-id");
    glade_property_set(startup_id_prop, "filler");
    glade_property_write(startup_id_prop, context, node);

    /* Chain up and write the parent's properties */
    GWA_GET_CLASS (GTK_TYPE_WINDOW)->write_widget (adaptor, widget, context, node);
}