-
Notifications
You must be signed in to change notification settings - Fork 346
/
SpokeWindow.c
156 lines (132 loc) · 5.73 KB
/
SpokeWindow.c
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
/*
* Copyright (C) 2011-2014 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/>.
*/
#include "config.h"
#include "BaseWindow.h"
#include "SpokeWindow.h"
#include "intl.h"
#include <atk/atk.h>
#include <gdk/gdkkeysyms.h>
/**
* SECTION: SpokeWindow
* @title: AnacondaSpokeWindow
* @short_description: Window for displaying single spokes
*
* A #AnacondaSpokeWindow is a widget that displays a single spoke on the
* screen. Examples include the keyboard and language configuration screens
* off the first hub.
*
* The AnacondaSpokeWindow consists of two areas:
*
* - A navigation area in the top of the screen, inherited from #AnacondaBaseWindow
* and augmented with a button in the upper left corner.
*
* - An action area in the rest of the screen, taking up a majority of the
* space. This is where widgets will be added and the user will do things.
*
* # CSS nodes
*
* |[<!-- language="plain" -->
* AnacondaSpokeWindow
* ╰── #anaconda-spoke-window-button
* ]|
*
* The button in the upper left is accessible as the name
* "anaconda-spoke-window-button" for the purposes of CSS selectors.
*/
#define DEFAULT_BUTTON_LABEL C_("GUI|Spoke Navigation", "_Done")
enum {
SIGNAL_BUTTON_CLICKED,
LAST_SIGNAL
};
static guint window_signals[LAST_SIGNAL] = { 0 };
struct _AnacondaSpokeWindowPrivate {
GtkWidget *button;
};
G_DEFINE_TYPE(AnacondaSpokeWindow, anaconda_spoke_window, ANACONDA_TYPE_BASE_WINDOW)
static void anaconda_spoke_window_button_clicked(GtkButton *button,
AnacondaSpokeWindow *win);
static void anaconda_spoke_window_class_init(AnacondaSpokeWindowClass *klass) {
GObjectClass *object_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
klass->button_clicked = NULL;
/**
* AnacondaSpokeWindow::button-clicked:
* @window: the window that received the signal
*
* Emitted when the button in the upper left corner has been activated
* (pressed and released). This is commonly the button that takes the user
* back to the hub, but could do other things. Note that we do not want
* to trap people in spokes, so there should always be a way back to the
* hub via this signal, even if it involves canceling some operation or
* resetting things.
*
* Since: 1.0
*/
window_signals[SIGNAL_BUTTON_CLICKED] = g_signal_new("button-clicked",
G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET(AnacondaSpokeWindowClass, button_clicked),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_type_class_add_private(object_class, sizeof(AnacondaSpokeWindowPrivate));
gtk_widget_class_set_css_name(widget_class, "AnacondaSpokeWindow");
}
/**
* anaconda_spoke_window_new:
*
* Creates a new #AnacondaSpokeWindow, which is a window designed for
* displaying a single spoke, such as the keyboard or network configuration
* screens.
*
* Returns: A new #AnacondaSpokeWindow.
*/
GtkWidget *anaconda_spoke_window_new() {
return g_object_new(ANACONDA_TYPE_SPOKE_WINDOW, NULL);
}
static void anaconda_spoke_window_init(AnacondaSpokeWindow *win) {
AtkObject *atk;
GtkWidget *nav_area;
GtkStyleContext *context;
win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win,
ANACONDA_TYPE_SPOKE_WINDOW,
AnacondaSpokeWindowPrivate);
/* Create the button. */
win->priv->button = gtk_button_new_with_mnemonic(DEFAULT_BUTTON_LABEL);
gtk_widget_set_halign(win->priv->button, GTK_ALIGN_START);
gtk_widget_set_vexpand(win->priv->button, FALSE);
gtk_widget_set_valign(win->priv->button, GTK_ALIGN_END);
gtk_widget_set_margin_bottom(win->priv->button, 6);
gtk_widget_set_name(win->priv->button, "anaconda-spoke-window-done");
atk = gtk_widget_get_accessible(win->priv->button);
atk_object_set_name(atk, DEFAULT_BUTTON_LABEL);
/* Set 'Done' button to blue 'suggested-action' style class */
context = gtk_widget_get_style_context(win->priv->button);
gtk_style_context_add_class(context, "suggested-action");
/* Hook up some signals for that button. The signal handlers here will
* just raise our own custom signals for the whole window.
*/
g_signal_connect(win->priv->button, "clicked",
G_CALLBACK(anaconda_spoke_window_button_clicked), win);
/* And then put the button into the navigation area. */
nav_area = anaconda_base_window_get_nav_area(ANACONDA_BASE_WINDOW(win));
gtk_grid_attach(GTK_GRID(nav_area), win->priv->button, 0, 1, 1, 2);
}
static void anaconda_spoke_window_button_clicked(GtkButton *button,
AnacondaSpokeWindow *win) {
g_signal_emit(win, window_signals[SIGNAL_BUTTON_CLICKED], 0);
}