summaryrefslogtreecommitdiffstats
path: root/widgets/src/StandaloneWindow.c
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2011-11-07 13:01:25 -0500
committerChris Lumens <clumens@redhat.com>2011-11-10 15:50:41 -0500
commitadd0aeee51989fbe0b5d3e6c46ac645a3bd734ef (patch)
tree02ad67539c2ecf55e90ecafbb7cb434a26d9fda2 /widgets/src/StandaloneWindow.c
parent732558a85699676d8c2975e8ed891eb07bcd77bc (diff)
downloadanaconda-add0aeee51989fbe0b5d3e6c46ac645a3bd734ef.tar.gz
anaconda-add0aeee51989fbe0b5d3e6c46ac645a3bd734ef.tar.xz
anaconda-add0aeee51989fbe0b5d3e6c46ac645a3bd734ef.zip
Add our custom GTK+ widgets in as a subdirectory and subpackage.
Diffstat (limited to 'widgets/src/StandaloneWindow.c')
-rw-r--r--widgets/src/StandaloneWindow.c194
1 files changed, 194 insertions, 0 deletions
diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c
new file mode 100644
index 000000000..6ba4031f0
--- /dev/null
+++ b/widgets/src/StandaloneWindow.c
@@ -0,0 +1,194 @@
+/*
+ * 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>
+ */
+
+#include "BaseWindow.h"
+#include "StandaloneWindow.h"
+#include "intl.h"
+
+/**
+ * SECTION: StandaloneWindow
+ * @title: AnacondaStandaloneWindow
+ * @short_description: Window for displaying standalone spokes
+ *
+ * A #AnacondaStandaloneWindow is a top-level window that displays a standalone
+ * spoke. A standalone spoke is like a normal spoke, but is not entered via a
+ * hub. Instead, it is displayed by itself. Examples include the welcome and
+ * network configuration screens at the beginning of installation.
+ *
+ * The window consist of three areas:
+ *
+ * - A navigation area in the top of the screen, inherited from #AnacondaBaseWindow.
+ *
+ * - A button box at the bottom of the screen, with Quit and Continue buttons.
+ * The Continue button may not be enabled until required information is
+ * entered by the user.
+ *
+ * - An action area in the middle of the screen, taking up a majority of the
+ * space. This is where widgets will be added and the user will do things.
+ */
+
+enum {
+ SIGNAL_QUIT_CLICKED,
+ SIGNAL_CONTINUE_CLICKED,
+ LAST_SIGNAL
+};
+
+static guint window_signals[LAST_SIGNAL] = { 0 };
+
+struct _AnacondaStandaloneWindowPrivate {
+ GtkWidget *button_box;
+ GtkWidget *continue_button, *quit_button;
+};
+
+static void anaconda_standalone_window_quit_clicked(GtkButton *button,
+ AnacondaStandaloneWindow *win);
+static void anaconda_standalone_window_continue_clicked(GtkButton *button,
+ AnacondaStandaloneWindow *win);
+
+G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW)
+
+static void anaconda_standalone_window_class_init(AnacondaStandaloneWindowClass *klass) {
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ klass->quit_clicked = NULL;
+ klass->continue_clicked = NULL;
+
+ /**
+ * AnacondaStandaloneWindow::quit-clicked:
+ * @window: the window that received the signal
+ *
+ * Emitted when the quit button has been activated (pressed and released).
+ *
+ * Since: 1.0
+ */
+ window_signals[SIGNAL_QUIT_CLICKED] = g_signal_new("quit-clicked",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(AnacondaStandaloneWindowClass, quit_clicked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * AnacondaStandaloneWindow::continue-clicked:
+ * @window: the window that received the signal
+ *
+ * Emitted when the continue button has been activated (pressed and released).
+ *
+ * Since: 1.0
+ */
+ window_signals[SIGNAL_CONTINUE_CLICKED] = g_signal_new("continue-clicked",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(AnacondaStandaloneWindowClass, continue_clicked),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private(object_class, sizeof(AnacondaStandaloneWindowPrivate));
+}
+
+/**
+ * anaconda_standalone_window_new:
+ *
+ * Creates a new #AnacondaStandaloneWindow, which is a window designed for
+ * displaying a standalone spoke, such as the welcome screen or network
+ * configuration.
+ *
+ * Returns: A new #AnacondaStandaloneWindow.
+ */
+GtkWidget *anaconda_standalone_window_new() {
+ return g_object_new(ANACONDA_TYPE_STANDALONE_WINDOW, NULL);
+}
+
+static void anaconda_standalone_window_init(AnacondaStandaloneWindow *win) {
+ /* This is the section of the parent AnacondaBaseWindow class where we
+ * put buttons, dialogs, etc. We need a reference to it here to pac
+ * things into.
+ */
+ GtkWidget *action_area = anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(win));
+
+ win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win,
+ ANACONDA_TYPE_STANDALONE_WINDOW,
+ AnacondaStandaloneWindowPrivate);
+
+ /* Create the buttons. */
+ win->priv->quit_button = gtk_button_new_with_mnemonic(_("_QUIT"));
+ win->priv->continue_button = gtk_button_new_with_mnemonic(_("_CONTINUE"));
+
+ /* Hook up some signals for those buttons. The signal handlers here will
+ * just raise our own custom signals for the whole window.
+ */
+ g_signal_connect(win->priv->quit_button, "clicked",
+ G_CALLBACK(anaconda_standalone_window_quit_clicked), win);
+ g_signal_connect(win->priv->continue_button, "clicked",
+ G_CALLBACK(anaconda_standalone_window_continue_clicked), win);
+
+ /* Create the button box and pack the buttons into it. */
+ win->priv->button_box = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(win->priv->button_box), GTK_BUTTONBOX_EDGE);
+ gtk_container_add(GTK_CONTAINER(win->priv->button_box), win->priv->quit_button);
+ gtk_container_add(GTK_CONTAINER(win->priv->button_box), win->priv->continue_button);
+
+ /* Pack the button box into the action_area. */
+ gtk_box_pack_end(GTK_BOX(action_area), win->priv->button_box, FALSE, TRUE, 0);
+}
+
+static void anaconda_standalone_window_quit_clicked(GtkButton *button,
+ AnacondaStandaloneWindow *win) {
+ g_signal_emit(win, window_signals[SIGNAL_QUIT_CLICKED], 0);
+}
+
+static void anaconda_standalone_window_continue_clicked(GtkButton *button,
+ AnacondaStandaloneWindow *win) {
+ g_signal_emit(win, window_signals[SIGNAL_CONTINUE_CLICKED], 0);
+}
+
+/**
+ * anaconda_standalone_window_get_may_continue:
+ * @win: a #AnacondaStandaloneWindow
+ *
+ * Returns whether or not the continue button is sensitive (thus, whether the
+ * user may continue forward from this window).
+ *
+ * Returns: Whether the continue button on @win is sensitive.
+ *
+ * Since: 1.0
+ */
+gboolean anaconda_standalone_window_get_may_continue(AnacondaStandaloneWindow *win) {
+ return gtk_widget_get_sensitive(win->priv->continue_button);
+}
+
+/**
+ * anaconda_standalone_window_set_may_continue:
+ * @win: a #AnacondaStandaloneWindow
+ * @may_continue: %TRUE if this window's continue button should be sensitive.
+ *
+ * Specifies whether the user may continue forward from this window. If so,
+ * the continue button will be made sensitive. Windows default to continuable
+ * so you must set it as false if you want. The reason the user may not be
+ * able to continue is if there is required information the user must enter
+ * when no reasonable default may be given.
+ *
+ * Since: 1.0
+ */
+void anaconda_standalone_window_set_may_continue(AnacondaStandaloneWindow *win,
+ gboolean may_continue) {
+ gtk_widget_set_sensitive(win->priv->continue_button, may_continue);
+}