2011-01-24 02:50:39 +00:00
|
|
|
|
/*
|
2008-07-01 22:57:50 +00:00
|
|
|
|
* GTK - The GIMP Toolkit
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* Copyright (C) 1999 Red Hat, Inc.
|
|
|
|
|
* Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
|
|
|
|
|
* Copyright (C) 2003 Matthias Clasen <mclasen@redhat.com>
|
|
|
|
|
* Copyright (C) 2005 Carlos Garnacho Parro <carlosg@gnome.org>
|
|
|
|
|
*
|
|
|
|
|
* 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; either
|
|
|
|
|
* version 2 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
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2010-03-05 22:44:31 +00:00
|
|
|
|
/**
|
|
|
|
|
* SECTION:gtkassistant
|
|
|
|
|
* @Short_description: A widget used to guide users through multi-step operations
|
|
|
|
|
* @Title: GtkAssistant
|
|
|
|
|
*
|
|
|
|
|
* A #GtkAssistant is a widget used to represent a generally complex
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* operation splitted in several steps, guiding the user through its
|
|
|
|
|
* pages and controlling the page flow to collect the necessary data.
|
2010-03-05 22:44:31 +00:00
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* The design of GtkAssistant is that it controls what buttons to show
|
|
|
|
|
* and to make sensitive, based on what it knows about the page sequence
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* and the [type][GtkAssistantPageType] of each page,
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* in addition to state information like the page
|
2014-02-07 02:07:03 +00:00
|
|
|
|
* [completion][gtk-assistant-set-page-complete]
|
|
|
|
|
* and [committed][gtk-assistant-commit] status.
|
2010-10-31 01:25:21 +00:00
|
|
|
|
*
|
2014-02-07 18:32:47 +00:00
|
|
|
|
* If you have a case that doesn’t quite fit in #GtkAssistants way of
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* handling buttons, you can use the #GTK_ASSISTANT_PAGE_CUSTOM page
|
|
|
|
|
* type and handle buttons yourself.
|
2010-10-31 18:34:35 +00:00
|
|
|
|
*
|
2019-02-07 20:18:49 +00:00
|
|
|
|
* GtkAssistant maintains a #GtkAssistantPage object for each added
|
|
|
|
|
* child, which holds additional per-child properties. You
|
|
|
|
|
* obtain the #GtkAssistantPage for a child with gtk_assistant_get_page().
|
|
|
|
|
*
|
2014-02-05 02:00:58 +00:00
|
|
|
|
* # GtkAssistant as GtkBuildable
|
2010-03-05 22:44:31 +00:00
|
|
|
|
*
|
2014-02-02 05:29:00 +00:00
|
|
|
|
* The GtkAssistant implementation of the #GtkBuildable interface
|
|
|
|
|
* exposes the @action_area as internal children with the name
|
2014-02-05 18:07:34 +00:00
|
|
|
|
* “action_area”.
|
2014-02-02 05:29:00 +00:00
|
|
|
|
*
|
|
|
|
|
* To add pages to an assistant in #GtkBuilder, simply add it as a
|
2019-02-07 20:18:49 +00:00
|
|
|
|
* child to the GtkAssistant object. If you need to set per-object
|
|
|
|
|
* properties, create a #GtkAssistantPage object explicitly, and
|
|
|
|
|
* set the child widget as a property on it.
|
2015-10-27 18:31:32 +00:00
|
|
|
|
*
|
|
|
|
|
* # CSS nodes
|
|
|
|
|
*
|
|
|
|
|
* GtkAssistant has a single CSS node with the name assistant.
|
2010-03-05 22:44:31 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
|
#include "config.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
#include "gtkassistant.h"
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
#include "gtkbox.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkbuildable.h"
|
|
|
|
|
#include "gtkbutton.h"
|
2011-05-18 21:22:40 +00:00
|
|
|
|
#include "gtkframe.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkheaderbar.h"
|
|
|
|
|
#include "gtkintl.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
|
#include "gtkimage.h"
|
|
|
|
|
#include "gtklabel.h"
|
2019-03-16 03:48:26 +00:00
|
|
|
|
#include "gtklistlistmodelprivate.h"
|
|
|
|
|
#include "gtkmaplistmodel.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
#include "gtkprivate.h"
|
2012-03-03 18:22:22 +00:00
|
|
|
|
#include "gtksettings.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
|
#include "gtksizegroup.h"
|
2010-09-09 13:35:58 +00:00
|
|
|
|
#include "gtksizerequest.h"
|
2019-03-16 03:48:26 +00:00
|
|
|
|
#include "gtkstack.h"
|
|
|
|
|
#include "gtkstylecontext.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
|
#include "gtktypebuiltins.h"
|
2018-02-08 23:42:38 +00:00
|
|
|
|
|
2011-07-04 01:34:54 +00:00
|
|
|
|
#include "a11y/gtkwindowaccessible.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
2019-05-27 01:08:01 +00:00
|
|
|
|
typedef struct _GtkAssistantPageClass GtkAssistantPageClass;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
struct _GtkAssistantPage
|
|
|
|
|
{
|
2019-02-07 20:18:49 +00:00
|
|
|
|
GObject instance;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkAssistantPageType type;
|
2011-04-17 00:45:26 +00:00
|
|
|
|
guint complete : 1;
|
2009-12-10 16:34:29 +00:00
|
|
|
|
guint complete_set : 1;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gchar *title;
|
|
|
|
|
|
|
|
|
|
GtkWidget *page;
|
|
|
|
|
GtkWidget *regular_title;
|
|
|
|
|
GtkWidget *current_title;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
struct _GtkAssistantPageClass
|
|
|
|
|
{
|
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-27 01:08:01 +00:00
|
|
|
|
typedef struct _GtkAssistantPrivate GtkAssistantPrivate;
|
|
|
|
|
typedef struct _GtkAssistantClass GtkAssistantClass;
|
|
|
|
|
|
|
|
|
|
struct _GtkAssistant
|
|
|
|
|
{
|
|
|
|
|
GtkWindow parent;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkAssistantClass
|
|
|
|
|
{
|
|
|
|
|
GtkWindowClass parent_class;
|
|
|
|
|
|
|
|
|
|
void (* prepare) (GtkAssistant *assistant, GtkWidget *page);
|
|
|
|
|
void (* apply) (GtkAssistant *assistant);
|
|
|
|
|
void (* close) (GtkAssistant *assistant);
|
|
|
|
|
void (* cancel) (GtkAssistant *assistant);
|
|
|
|
|
};
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
struct _GtkAssistantPrivate
|
|
|
|
|
{
|
2010-05-24 13:46:51 +00:00
|
|
|
|
GtkWidget *cancel;
|
|
|
|
|
GtkWidget *forward;
|
|
|
|
|
GtkWidget *back;
|
|
|
|
|
GtkWidget *apply;
|
|
|
|
|
GtkWidget *close;
|
|
|
|
|
GtkWidget *last;
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GtkWidget *sidebar;
|
|
|
|
|
GtkWidget *content;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkWidget *action_area;
|
2014-01-29 02:27:26 +00:00
|
|
|
|
GtkWidget *headerbar;
|
|
|
|
|
gint use_header_bar;
|
|
|
|
|
gboolean constructed;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
GList *pages;
|
|
|
|
|
GSList *visited_pages;
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GtkAssistantPage *current_page;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GtkSizeGroup *button_size_group;
|
|
|
|
|
GtkSizeGroup *title_size_group;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
GtkAssistantPageFunc forward_function;
|
|
|
|
|
gpointer forward_function_data;
|
|
|
|
|
GDestroyNotify forward_data_destroy;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
GListModel *model;
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gint extra_buttons;
|
|
|
|
|
|
2010-06-02 20:00:16 +00:00
|
|
|
|
guint committed : 1;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
|
static void gtk_assistant_destroy (GtkWidget *widget);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static void gtk_assistant_map (GtkWidget *widget);
|
|
|
|
|
static void gtk_assistant_unmap (GtkWidget *widget);
|
2018-01-01 20:24:16 +00:00
|
|
|
|
static gboolean gtk_assistant_close_request (GtkWindow *window);
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static void gtk_assistant_add (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static void gtk_assistant_remove (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page);
|
2019-02-07 20:18:49 +00:00
|
|
|
|
static void gtk_assistant_page_set_property (GObject *object,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2019-02-07 20:18:49 +00:00
|
|
|
|
static void gtk_assistant_page_get_property (GObject *object,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-08-29 13:21:20 +00:00
|
|
|
|
static void gtk_assistant_buildable_interface_init (GtkBuildableIface *iface);
|
|
|
|
|
static void gtk_assistant_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const char *type);
|
|
|
|
|
static gboolean gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
GtkBuildableParser *parser,
|
|
|
|
|
gpointer *data);
|
|
|
|
|
static void gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
static GList* find_page (GtkAssistant *assistant,
|
|
|
|
|
GtkWidget *page);
|
|
|
|
|
static void on_assistant_close (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
static void on_assistant_apply (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
static void on_assistant_forward (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
static void on_assistant_back (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
static void on_assistant_cancel (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
static void on_assistant_last (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
static void assistant_remove_page_cb (GtkContainer *container,
|
|
|
|
|
GtkWidget *page,
|
|
|
|
|
GtkAssistant *assistant);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int gtk_assistant_add_page (GtkAssistant *assistant,
|
|
|
|
|
GtkAssistantPage *page_info,
|
|
|
|
|
gint position);
|
|
|
|
|
|
|
|
|
|
GType _gtk_assistant_accessible_get_type (void);
|
2011-07-06 16:34:50 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
CHILD_PROP_0,
|
2019-02-07 20:18:49 +00:00
|
|
|
|
CHILD_PROP_CHILD,
|
2006-01-18 22:39:14 +00:00
|
|
|
|
CHILD_PROP_PAGE_TYPE,
|
|
|
|
|
CHILD_PROP_PAGE_TITLE,
|
2015-06-15 01:29:09 +00:00
|
|
|
|
CHILD_PROP_PAGE_COMPLETE,
|
|
|
|
|
CHILD_PROP_HAS_PADDING
|
2006-01-18 22:39:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
G_DEFINE_TYPE (GtkAssistantPage, gtk_assistant_page, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_page_init (GtkAssistantPage *page)
|
|
|
|
|
{
|
|
|
|
|
page->type = GTK_ASSISTANT_PAGE_CONTENT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_page_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page = GTK_ASSISTANT_PAGE (object);
|
|
|
|
|
|
|
|
|
|
g_clear_object (&page->page);
|
|
|
|
|
g_free (page->title);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_assistant_page_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_page_class_init (GtkAssistantPageClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
|
|
object_class->finalize = gtk_assistant_page_finalize;
|
|
|
|
|
object_class->get_property = gtk_assistant_page_get_property;
|
|
|
|
|
object_class->set_property = gtk_assistant_page_set_property;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkAssistantPage:page-type:
|
|
|
|
|
*
|
|
|
|
|
* The type of the assistant page.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
CHILD_PROP_PAGE_TYPE,
|
|
|
|
|
g_param_spec_enum ("page-type",
|
|
|
|
|
P_("Page type"),
|
|
|
|
|
P_("The type of the assistant page"),
|
|
|
|
|
GTK_TYPE_ASSISTANT_PAGE_TYPE,
|
|
|
|
|
GTK_ASSISTANT_PAGE_CONTENT,
|
2019-02-08 14:03:18 +00:00
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkAssistantPage:title:
|
|
|
|
|
*
|
|
|
|
|
* The title of the page.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
CHILD_PROP_PAGE_TITLE,
|
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
|
P_("Page title"),
|
|
|
|
|
P_("The title of the assistant page"),
|
|
|
|
|
NULL,
|
2019-02-08 14:03:18 +00:00
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkAssistantPage:complete:
|
|
|
|
|
*
|
|
|
|
|
* Setting the "complete" property to %TRUE marks a page as
|
|
|
|
|
* complete (i.e.: all the required fields are filled out). GTK+ uses
|
|
|
|
|
* this information to control the sensitivity of the navigation buttons.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
CHILD_PROP_PAGE_COMPLETE,
|
|
|
|
|
g_param_spec_boolean ("complete",
|
|
|
|
|
P_("Page complete"),
|
|
|
|
|
P_("Whether all required fields on the page have been filled out"),
|
|
|
|
|
FALSE,
|
2019-02-08 14:03:18 +00:00
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_object_class_install_property (object_class,
|
|
|
|
|
CHILD_PROP_CHILD,
|
|
|
|
|
g_param_spec_object ("child",
|
|
|
|
|
P_("Child widget"),
|
|
|
|
|
P_("The content the assistant page"),
|
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
CANCEL,
|
|
|
|
|
PREPARE,
|
|
|
|
|
APPLY,
|
|
|
|
|
CLOSE,
|
2014-09-08 04:08:01 +00:00
|
|
|
|
ESCAPE,
|
2006-01-18 22:39:14 +00:00
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
enum {
|
|
|
|
|
PROP_0,
|
2019-02-13 23:27:25 +00:00
|
|
|
|
PROP_USE_HEADER_BAR,
|
|
|
|
|
PROP_PAGES
|
2014-01-29 02:27:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static guint signals [LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2009-04-18 05:23:20 +00:00
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkAssistant, gtk_assistant, GTK_TYPE_WINDOW,
|
2013-06-27 19:02:52 +00:00
|
|
|
|
G_ADD_PRIVATE (GtkAssistant)
|
2009-04-18 05:23:20 +00:00
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
|
gtk_assistant_buildable_interface_init))
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
static void
|
|
|
|
|
set_use_header_bar (GtkAssistant *assistant,
|
|
|
|
|
gint use_header_bar)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
if (use_header_bar == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
priv->use_header_bar = use_header_bar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_set_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_USE_HEADER_BAR:
|
|
|
|
|
set_use_header_bar (assistant, g_value_get_int (value));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_get_property (GObject *object,
|
|
|
|
|
guint prop_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (object);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
|
{
|
|
|
|
|
case PROP_USE_HEADER_BAR:
|
|
|
|
|
g_value_set_int (value, priv->use_header_bar);
|
|
|
|
|
break;
|
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
case PROP_PAGES:
|
|
|
|
|
g_value_set_object (value, gtk_assistant_get_pages (assistant));
|
|
|
|
|
break;
|
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_cb (GtkContainer *container,
|
|
|
|
|
GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
if (priv->use_header_bar)
|
2019-08-25 12:52:24 +00:00
|
|
|
|
g_warning ("Content added to the action area of an assistant using header bars");
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (container));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
apply_use_header_bar (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_set_visible (priv->action_area, !priv->use_header_bar);
|
|
|
|
|
gtk_widget_set_visible (priv->headerbar, priv->use_header_bar);
|
|
|
|
|
if (!priv->use_header_bar)
|
|
|
|
|
gtk_window_set_titlebar (GTK_WINDOW (assistant), NULL);
|
2016-01-27 17:57:58 +00:00
|
|
|
|
else
|
2014-01-29 02:27:26 +00:00
|
|
|
|
g_signal_connect (priv->action_area, "add", G_CALLBACK (add_cb), assistant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_to_header_bar (GtkAssistant *assistant,
|
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
|
|
|
|
|
|
|
|
|
|
if (child == priv->back || child == priv->cancel)
|
|
|
|
|
gtk_header_bar_pack_start (GTK_HEADER_BAR (priv->headerbar), child);
|
|
|
|
|
else
|
|
|
|
|
gtk_header_bar_pack_end (GTK_HEADER_BAR (priv->headerbar), child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
add_action_widgets (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
GList *children;
|
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
|
|
if (priv->use_header_bar)
|
|
|
|
|
{
|
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
|
|
|
|
|
for (l = children; l != NULL; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *child = l->data;
|
|
|
|
|
gboolean has_default;
|
|
|
|
|
|
|
|
|
|
has_default = gtk_widget_has_default (child);
|
|
|
|
|
|
|
|
|
|
g_object_ref (child);
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->action_area), child);
|
|
|
|
|
add_to_header_bar (assistant, child);
|
|
|
|
|
g_object_unref (child);
|
|
|
|
|
|
|
|
|
|
if (has_default)
|
|
|
|
|
{
|
2019-04-27 03:20:41 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (assistant), child);
|
2014-02-07 15:25:00 +00:00
|
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (child), GTK_STYLE_CLASS_SUGGESTED_ACTION);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
g_list_free (children);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_constructed (GObject *object)
|
2014-01-29 02:27:26 +00:00
|
|
|
|
{
|
2014-06-26 22:22:42 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (object);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
2014-06-26 22:22:42 +00:00
|
|
|
|
G_OBJECT_CLASS (gtk_assistant_parent_class)->constructed (object);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
priv->constructed = TRUE;
|
|
|
|
|
if (priv->use_header_bar == -1)
|
|
|
|
|
priv->use_header_bar = FALSE;
|
|
|
|
|
|
|
|
|
|
add_action_widgets (assistant);
|
|
|
|
|
apply_use_header_bar (assistant);
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2014-09-08 04:08:01 +00:00
|
|
|
|
static void
|
|
|
|
|
escape_cb (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-09-08 04:08:01 +00:00
|
|
|
|
|
|
|
|
|
/* Do not allow cancelling in the middle of a progress page */
|
|
|
|
|
if (priv->current_page &&
|
|
|
|
|
(priv->current_page->type != GTK_ASSISTANT_PAGE_PROGRESS ||
|
|
|
|
|
priv->current_page->complete))
|
|
|
|
|
g_signal_emit (assistant, signals [CANCEL], 0, NULL);
|
|
|
|
|
|
|
|
|
|
/* don't run any user handlers - this is not a public signal */
|
|
|
|
|
g_signal_stop_emission (assistant, signals[ESCAPE], 0);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-21 02:45:11 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (object);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2019-02-21 02:45:11 +00:00
|
|
|
|
|
|
|
|
|
if (priv->model)
|
|
|
|
|
g_object_remove_weak_pointer (G_OBJECT (priv->model), (gpointer *)&priv->model);
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_assistant_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_class_init (GtkAssistantClass *class)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
GtkContainerClass *container_class;
|
2018-01-01 20:24:16 +00:00
|
|
|
|
GtkWindowClass *window_class;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) class;
|
|
|
|
|
widget_class = (GtkWidgetClass *) class;
|
|
|
|
|
container_class = (GtkContainerClass *) class;
|
2018-01-01 20:24:16 +00:00
|
|
|
|
window_class = (GtkWindowClass *) class;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-02-21 02:45:11 +00:00
|
|
|
|
gobject_class->finalize = gtk_assistant_finalize;
|
2014-06-26 22:22:42 +00:00
|
|
|
|
gobject_class->constructed = gtk_assistant_constructed;
|
2014-01-29 02:27:26 +00:00
|
|
|
|
gobject_class->set_property = gtk_assistant_set_property;
|
|
|
|
|
gobject_class->get_property = gtk_assistant_get_property;
|
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
|
widget_class->destroy = gtk_assistant_destroy;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
widget_class->map = gtk_assistant_map;
|
|
|
|
|
widget_class->unmap = gtk_assistant_unmap;
|
2011-07-06 16:34:50 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_set_accessible_type (widget_class, _gtk_assistant_accessible_get_type ());
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
container_class->add = gtk_assistant_add;
|
|
|
|
|
container_class->remove = gtk_assistant_remove;
|
|
|
|
|
|
2018-01-01 20:24:16 +00:00
|
|
|
|
window_class->close_request = gtk_assistant_close_request;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkAssistant::cancel:
|
|
|
|
|
* @assistant: the #GtkAssistant
|
|
|
|
|
*
|
|
|
|
|
* The ::cancel signal is emitted when then the cancel button is clicked.
|
|
|
|
|
*/
|
|
|
|
|
signals[CANCEL] =
|
|
|
|
|
g_signal_new (I_("cancel"),
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkAssistantClass, cancel),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkAssistant::prepare:
|
|
|
|
|
* @assistant: the #GtkAssistant
|
|
|
|
|
* @page: the current page
|
|
|
|
|
*
|
2011-04-17 00:45:26 +00:00
|
|
|
|
* The ::prepare signal is emitted when a new page is set as the
|
|
|
|
|
* assistant's current page, before making the new page visible.
|
|
|
|
|
*
|
|
|
|
|
* A handler for this signal can do any preparations which are
|
|
|
|
|
* necessary before showing @page.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*/
|
|
|
|
|
signals[PREPARE] =
|
|
|
|
|
g_signal_new (I_("prepare"),
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkAssistantClass, prepare),
|
|
|
|
|
NULL, NULL,
|
2019-05-31 03:56:50 +00:00
|
|
|
|
NULL,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_NONE, 1, GTK_TYPE_WIDGET);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkAssistant::apply:
|
2010-03-05 22:44:31 +00:00
|
|
|
|
* @assistant: the #GtkAssistant
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*
|
2011-04-17 00:45:26 +00:00
|
|
|
|
* The ::apply signal is emitted when the apply button is clicked.
|
|
|
|
|
*
|
|
|
|
|
* The default behavior of the #GtkAssistant is to switch to the page
|
|
|
|
|
* after the current page, unless the current page is the last one.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*
|
2011-04-17 00:45:26 +00:00
|
|
|
|
* A handler for the ::apply signal should carry out the actions for
|
|
|
|
|
* which the wizard has collected data. If the action takes a long time
|
|
|
|
|
* to complete, you might consider putting a page of type
|
|
|
|
|
* %GTK_ASSISTANT_PAGE_PROGRESS after the confirmation page and handle
|
|
|
|
|
* this operation within the #GtkAssistant::prepare signal of the progress
|
|
|
|
|
* page.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*/
|
|
|
|
|
signals[APPLY] =
|
|
|
|
|
g_signal_new (I_("apply"),
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkAssistantClass, apply),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GtkAssistant::close:
|
|
|
|
|
* @assistant: the #GtkAssistant
|
|
|
|
|
*
|
2006-01-28 06:03:50 +00:00
|
|
|
|
* The ::close signal is emitted either when the close button of
|
|
|
|
|
* a summary page is clicked, or when the apply button in the last
|
2009-05-30 06:14:03 +00:00
|
|
|
|
* page in the flow (of type %GTK_ASSISTANT_PAGE_CONFIRM) is clicked.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*/
|
|
|
|
|
signals[CLOSE] =
|
|
|
|
|
g_signal_new (I_("close"),
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
G_STRUCT_OFFSET (GtkAssistantClass, close),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2014-09-08 04:08:01 +00:00
|
|
|
|
signals[ESCAPE] =
|
|
|
|
|
g_signal_new_class_handler (I_("escape"),
|
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
|
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
|
|
|
G_CALLBACK (escape_cb),
|
|
|
|
|
NULL, NULL,
|
2019-05-29 20:05:19 +00:00
|
|
|
|
NULL,
|
2014-09-08 04:08:01 +00:00
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
|
2018-08-05 02:20:58 +00:00
|
|
|
|
gtk_widget_class_add_binding_signal (widget_class,
|
|
|
|
|
GDK_KEY_Escape, 0,
|
|
|
|
|
"escape",
|
|
|
|
|
NULL);
|
2014-09-08 04:08:01 +00:00
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
/**
|
|
|
|
|
* GtkAssistant:use-header-bar:
|
|
|
|
|
*
|
|
|
|
|
* %TRUE if the assistant uses a #GtkHeaderBar for action buttons
|
|
|
|
|
* instead of the action-area.
|
|
|
|
|
*
|
|
|
|
|
* For technical reasons, this property is declared as an integer
|
|
|
|
|
* property, but you should only set it to %TRUE or %FALSE.
|
|
|
|
|
*/
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_USE_HEADER_BAR,
|
|
|
|
|
g_param_spec_int ("use-header-bar",
|
|
|
|
|
P_("Use Header Bar"),
|
|
|
|
|
P_("Use Header Bar for actions."),
|
|
|
|
|
-1, 1, -1,
|
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
|
PROP_PAGES,
|
|
|
|
|
g_param_spec_object ("pages",
|
|
|
|
|
P_("Pages"),
|
2019-02-21 12:28:37 +00:00
|
|
|
|
P_("The pages of the assistant."),
|
2019-02-13 23:27:25 +00:00
|
|
|
|
G_TYPE_LIST_MODEL,
|
|
|
|
|
GTK_PARAM_READABLE));
|
2015-06-15 01:29:09 +00:00
|
|
|
|
|
2013-03-23 10:10:34 +00:00
|
|
|
|
/* Bind class to template
|
|
|
|
|
*/
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class,
|
2014-01-23 23:59:20 +00:00
|
|
|
|
"/org/gtk/libgtk/ui/gtkassistant.ui");
|
2013-03-23 10:10:34 +00:00
|
|
|
|
|
2013-07-26 20:29:12 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkAssistant, action_area);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_internal_private (widget_class, GtkAssistant, headerbar);
|
2013-07-26 20:29:12 +00:00
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, content);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, cancel);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, forward);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, back);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, apply);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, close);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, last);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, sidebar);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, button_size_group);
|
|
|
|
|
gtk_widget_class_bind_template_child_private (widget_class, GtkAssistant, title_size_group);
|
2013-07-26 17:49:49 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, assistant_remove_page_cb);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_assistant_close);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_assistant_apply);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_assistant_forward);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_assistant_back);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_assistant_cancel);
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_assistant_last);
|
2015-10-27 18:31:32 +00:00
|
|
|
|
|
2017-11-18 03:49:57 +00:00
|
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("assistant"));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
default_forward_function (gint current_page, gpointer data)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (data);
|
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *page_node;
|
|
|
|
|
|
|
|
|
|
page_node = g_list_nth (priv->pages, ++current_page);
|
|
|
|
|
|
|
|
|
|
if (!page_node)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage *) page_node->data;
|
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
|
while (page_node && !gtk_widget_get_visible (page_info->page))
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
page_node = page_node->next;
|
|
|
|
|
current_page++;
|
2006-01-28 06:03:50 +00:00
|
|
|
|
|
|
|
|
|
if (page_node)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
page_info = (GtkAssistantPage *) page_node->data;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return current_page;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
last_button_visible (GtkAssistant *assistant, GtkAssistantPage *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GtkAssistantPage *page_info;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gint count, page_num, n_pages;
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (page == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (page->type != GTK_ASSISTANT_PAGE_CONTENT)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
count = 0;
|
2011-04-17 00:45:26 +00:00
|
|
|
|
page_num = g_list_index (priv->pages, page);
|
|
|
|
|
n_pages = g_list_length (priv->pages);
|
|
|
|
|
page_info = page;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2006-01-23 19:11:40 +00:00
|
|
|
|
while (page_num >= 0 && page_num < n_pages &&
|
2011-01-24 02:50:39 +00:00
|
|
|
|
page_info->type == GTK_ASSISTANT_PAGE_CONTENT &&
|
|
|
|
|
(count == 0 || page_info->complete) &&
|
|
|
|
|
count < n_pages)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2006-01-23 19:11:40 +00:00
|
|
|
|
page_num = (priv->forward_function) (page_num, priv->forward_function_data);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
page_info = g_list_nth_data (priv->pages, page_num);
|
2006-01-23 19:11:40 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
/* Make the last button visible if we can skip multiple
|
2009-05-30 06:14:03 +00:00
|
|
|
|
* pages and end on a confirmation or summary page
|
2006-01-23 19:11:40 +00:00
|
|
|
|
*/
|
2009-05-30 06:14:03 +00:00
|
|
|
|
if (count > 1 && page_info &&
|
2006-01-23 19:11:40 +00:00
|
|
|
|
(page_info->type == GTK_ASSISTANT_PAGE_CONFIRM ||
|
|
|
|
|
page_info->type == GTK_ASSISTANT_PAGE_SUMMARY))
|
2011-04-17 00:45:26 +00:00
|
|
|
|
return TRUE;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
else
|
2011-04-17 00:45:26 +00:00
|
|
|
|
return FALSE;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-02 20:00:16 +00:00
|
|
|
|
static void
|
2011-04-17 00:45:26 +00:00
|
|
|
|
update_actions_size (GtkAssistant *assistant)
|
2010-06-02 20:00:16 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GList *l;
|
|
|
|
|
GtkAssistantPage *page;
|
|
|
|
|
gint buttons, page_buttons;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (!priv->current_page)
|
|
|
|
|
return;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
/* Some heuristics to find out how many buttons we should
|
|
|
|
|
* reserve space for. It is possible to trick this code
|
|
|
|
|
* with page forward functions and invisible pages, etc.
|
|
|
|
|
*/
|
|
|
|
|
buttons = 0;
|
|
|
|
|
for (l = priv->pages; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
page = l->data;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (!gtk_widget_get_visible (page->page))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
page_buttons = 2; /* cancel, forward/apply/close */
|
|
|
|
|
if (l != priv->pages)
|
|
|
|
|
page_buttons += 1; /* back */
|
|
|
|
|
if (last_button_visible (assistant, page))
|
|
|
|
|
page_buttons += 1; /* last */
|
|
|
|
|
|
|
|
|
|
buttons = MAX (buttons, page_buttons);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buttons += priv->extra_buttons;
|
|
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (priv->action_area,
|
|
|
|
|
buttons * gtk_widget_get_allocated_width (priv->cancel) + (buttons - 1) * 6,
|
|
|
|
|
-1);
|
2010-06-02 20:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static void
|
2011-04-17 00:45:26 +00:00
|
|
|
|
compute_last_button_state (GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->last, priv->current_page->complete);
|
|
|
|
|
if (last_button_visible (assistant, priv->current_page))
|
|
|
|
|
gtk_widget_show (priv->last);
|
|
|
|
|
else
|
|
|
|
|
gtk_widget_hide (priv->last);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-04-17 00:45:26 +00:00
|
|
|
|
compute_progress_state (GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gint page_num, n_pages;
|
|
|
|
|
|
|
|
|
|
n_pages = gtk_assistant_get_n_pages (assistant);
|
|
|
|
|
page_num = gtk_assistant_get_current_page (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
page_num = (priv->forward_function) (page_num, priv->forward_function_data);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (page_num >= 0 && page_num < n_pages)
|
|
|
|
|
gtk_widget_show (priv->forward);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
else
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gtk_widget_hide (priv->forward);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2011-04-17 00:45:26 +00:00
|
|
|
|
update_buttons_state (GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2007-06-06 14:24:31 +00:00
|
|
|
|
if (!priv->current_page)
|
|
|
|
|
return;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
switch (priv->current_page->type)
|
|
|
|
|
{
|
|
|
|
|
case GTK_ASSISTANT_PAGE_INTRO:
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->cancel, TRUE);
|
|
|
|
|
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
|
2019-04-27 03:20:41 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_show (priv->forward);
|
|
|
|
|
gtk_widget_hide (priv->back);
|
|
|
|
|
gtk_widget_hide (priv->apply);
|
|
|
|
|
gtk_widget_hide (priv->close);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
compute_last_button_state (assistant);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_ASSISTANT_PAGE_CONFIRM:
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->cancel, TRUE);
|
|
|
|
|
gtk_widget_set_sensitive (priv->back, TRUE);
|
|
|
|
|
gtk_widget_set_sensitive (priv->apply, priv->current_page->complete);
|
2019-04-27 03:20:41 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->apply);
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_show (priv->back);
|
|
|
|
|
gtk_widget_show (priv->apply);
|
|
|
|
|
gtk_widget_hide (priv->forward);
|
|
|
|
|
gtk_widget_hide (priv->close);
|
|
|
|
|
gtk_widget_hide (priv->last);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_ASSISTANT_PAGE_CONTENT:
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->cancel, TRUE);
|
|
|
|
|
gtk_widget_set_sensitive (priv->back, TRUE);
|
|
|
|
|
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
|
2019-04-27 03:20:41 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_show (priv->back);
|
|
|
|
|
gtk_widget_show (priv->forward);
|
|
|
|
|
gtk_widget_hide (priv->apply);
|
|
|
|
|
gtk_widget_hide (priv->close);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
compute_last_button_state (assistant);
|
|
|
|
|
break;
|
|
|
|
|
case GTK_ASSISTANT_PAGE_SUMMARY:
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->close, priv->current_page->complete);
|
2019-04-27 03:20:41 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->close);
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_show (priv->close);
|
|
|
|
|
gtk_widget_hide (priv->back);
|
|
|
|
|
gtk_widget_hide (priv->forward);
|
|
|
|
|
gtk_widget_hide (priv->apply);
|
|
|
|
|
gtk_widget_hide (priv->last);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case GTK_ASSISTANT_PAGE_PROGRESS:
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_set_sensitive (priv->cancel, priv->current_page->complete);
|
|
|
|
|
gtk_widget_set_sensitive (priv->back, priv->current_page->complete);
|
|
|
|
|
gtk_widget_set_sensitive (priv->forward, priv->current_page->complete);
|
2019-04-27 03:20:41 +00:00
|
|
|
|
gtk_window_set_default_widget (GTK_WINDOW (assistant), priv->forward);
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_show (priv->back);
|
|
|
|
|
gtk_widget_hide (priv->apply);
|
|
|
|
|
gtk_widget_hide (priv->close);
|
|
|
|
|
gtk_widget_hide (priv->last);
|
2010-06-02 20:00:16 +00:00
|
|
|
|
compute_progress_state (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2010-10-30 19:12:58 +00:00
|
|
|
|
case GTK_ASSISTANT_PAGE_CUSTOM:
|
|
|
|
|
gtk_widget_hide (priv->cancel);
|
|
|
|
|
gtk_widget_hide (priv->back);
|
|
|
|
|
gtk_widget_hide (priv->forward);
|
|
|
|
|
gtk_widget_hide (priv->apply);
|
|
|
|
|
gtk_widget_hide (priv->last);
|
|
|
|
|
gtk_widget_hide (priv->close);
|
|
|
|
|
break;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
default:
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-02 20:00:16 +00:00
|
|
|
|
if (priv->committed)
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_hide (priv->cancel);
|
2010-10-30 19:12:58 +00:00
|
|
|
|
else if (priv->current_page->type == GTK_ASSISTANT_PAGE_SUMMARY ||
|
|
|
|
|
priv->current_page->type == GTK_ASSISTANT_PAGE_CUSTOM)
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_hide (priv->cancel);
|
2010-06-02 20:00:16 +00:00
|
|
|
|
else
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_show (priv->cancel);
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/* this is quite general, we don't want to
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* go back if it's the first page
|
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
if (!priv->visited_pages)
|
2010-05-24 13:46:51 +00:00
|
|
|
|
gtk_widget_hide (priv->back);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
update_page_title_state (GtkAssistant *assistant, GList *list)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GtkAssistantPage *page, *other;
|
|
|
|
|
gboolean visible;
|
|
|
|
|
GList *l;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
page = list->data;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (page->title == NULL || page->title[0] == 0)
|
|
|
|
|
visible = FALSE;
|
|
|
|
|
else
|
|
|
|
|
visible = gtk_widget_get_visible (page->page);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (page == priv->current_page)
|
|
|
|
|
{
|
|
|
|
|
gtk_widget_set_visible (page->regular_title, FALSE);
|
|
|
|
|
gtk_widget_set_visible (page->current_title, visible);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* If multiple consecutive pages have the same title,
|
|
|
|
|
* we only show it once, since it would otherwise look
|
|
|
|
|
* silly. We have to be a little careful, since we
|
|
|
|
|
* _always_ show the title of the current page.
|
|
|
|
|
*/
|
|
|
|
|
if (list->prev)
|
|
|
|
|
{
|
|
|
|
|
other = list->prev->data;
|
|
|
|
|
if (g_strcmp0 (page->title, other->title) == 0)
|
|
|
|
|
visible = FALSE;
|
|
|
|
|
}
|
|
|
|
|
for (l = list->next; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
other = l->data;
|
|
|
|
|
if (g_strcmp0 (page->title, other->title) != 0)
|
|
|
|
|
break;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (other == priv->current_page)
|
|
|
|
|
{
|
|
|
|
|
visible = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gtk_widget_set_visible (page->regular_title, visible);
|
|
|
|
|
gtk_widget_set_visible (page->current_title, FALSE);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
return visible;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
update_title_state (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
GList *l;
|
|
|
|
|
gboolean show_titles;
|
|
|
|
|
|
|
|
|
|
show_titles = FALSE;
|
|
|
|
|
for (l = priv->pages; l != NULL; l = l->next)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (update_page_title_state (assistant, l))
|
|
|
|
|
show_titles = TRUE;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-03 15:33:54 +00:00
|
|
|
|
gtk_widget_set_visible (priv->sidebar, show_titles);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
set_current_page (GtkAssistant *assistant,
|
|
|
|
|
gint page_num)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
|
|
|
|
|
priv->current_page = (GtkAssistantPage *)g_list_nth_data (priv->pages, page_num);
|
|
|
|
|
|
|
|
|
|
g_signal_emit (assistant, signals [PREPARE], 0, priv->current_page->page);
|
2012-09-08 12:21:32 +00:00
|
|
|
|
/* do not continue if the prepare signal handler has already changed the
|
|
|
|
|
* current page */
|
|
|
|
|
if (priv->current_page != (GtkAssistantPage *)g_list_nth_data (priv->pages, page_num))
|
|
|
|
|
return;
|
2011-04-17 00:45:26 +00:00
|
|
|
|
|
|
|
|
|
update_title_state (assistant);
|
|
|
|
|
|
2014-01-29 03:36:16 +00:00
|
|
|
|
gtk_window_set_title (GTK_WINDOW (assistant), priv->current_page->title);
|
|
|
|
|
|
2019-02-14 19:46:01 +00:00
|
|
|
|
gtk_stack_set_visible_child (GTK_STACK (priv->content), priv->current_page->page);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
|
|
|
|
|
/* update buttons state, flow may have changed */
|
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
|
|
|
|
update_buttons_state (assistant);
|
|
|
|
|
|
2009-02-17 05:36:12 +00:00
|
|
|
|
if (!gtk_widget_child_focus (priv->current_page->page, GTK_DIR_TAB_FORWARD))
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *button[6];
|
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
|
|
/* find the best button to focus */
|
2010-05-24 13:46:51 +00:00
|
|
|
|
button[0] = priv->apply;
|
|
|
|
|
button[1] = priv->close;
|
|
|
|
|
button[2] = priv->forward;
|
|
|
|
|
button[3] = priv->back;
|
|
|
|
|
button[4] = priv->cancel;
|
|
|
|
|
button[5] = priv->last;
|
2009-02-17 05:36:12 +00:00
|
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
|
{
|
2011-01-24 02:50:39 +00:00
|
|
|
|
if (gtk_widget_get_visible (button[i]) &&
|
|
|
|
|
gtk_widget_get_sensitive (button[i]))
|
2009-02-17 05:36:12 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_widget_grab_focus (button[i]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
|
compute_next_step (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
gint current_page, n_pages, next_page;
|
|
|
|
|
|
|
|
|
|
current_page = gtk_assistant_get_current_page (assistant);
|
|
|
|
|
page_info = priv->current_page;
|
|
|
|
|
n_pages = gtk_assistant_get_n_pages (assistant);
|
|
|
|
|
|
|
|
|
|
next_page = (priv->forward_function) (current_page,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
priv->forward_function_data);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
if (next_page >= 0 && next_page < n_pages)
|
|
|
|
|
{
|
|
|
|
|
priv->visited_pages = g_slist_prepend (priv->visited_pages, page_info);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
set_current_page (assistant, next_page);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-12 15:20:19 +00:00
|
|
|
|
on_assistant_close (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_emit (assistant, signals [CLOSE], 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-12 15:20:19 +00:00
|
|
|
|
on_assistant_apply (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
gboolean success;
|
|
|
|
|
|
2008-07-18 19:07:39 +00:00
|
|
|
|
g_signal_emit (assistant, signals [APPLY], 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2009-08-07 03:52:18 +00:00
|
|
|
|
success = compute_next_step (assistant);
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/* if the assistant hasn't switched to another page, just emit
|
|
|
|
|
* the CLOSE signal, it't the last page in the assistant flow
|
|
|
|
|
*/
|
|
|
|
|
if (!success)
|
2008-07-18 19:07:39 +00:00
|
|
|
|
g_signal_emit (assistant, signals [CLOSE], 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-12 15:20:19 +00:00
|
|
|
|
on_assistant_forward (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2010-10-30 19:12:58 +00:00
|
|
|
|
gtk_assistant_next_page (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-12 15:20:19 +00:00
|
|
|
|
on_assistant_back (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2010-10-30 19:12:58 +00:00
|
|
|
|
gtk_assistant_previous_page (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-12 15:20:19 +00:00
|
|
|
|
on_assistant_cancel (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
g_signal_emit (assistant, signals [CANCEL], 0, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-08-12 15:20:19 +00:00
|
|
|
|
on_assistant_last (GtkWidget *widget,
|
|
|
|
|
GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
while (priv->current_page->type == GTK_ASSISTANT_PAGE_CONTENT &&
|
2011-01-24 02:50:39 +00:00
|
|
|
|
priv->current_page->complete)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
compute_next_step (assistant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
alternative_button_order (GtkAssistant *assistant)
|
|
|
|
|
{
|
|
|
|
|
gboolean result;
|
|
|
|
|
|
2017-10-30 23:07:14 +00:00
|
|
|
|
g_object_get (gtk_widget_get_settings (GTK_WIDGET (assistant)),
|
2011-01-24 02:50:39 +00:00
|
|
|
|
"gtk-alternative-button-order", &result,
|
|
|
|
|
NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-09 18:48:04 +00:00
|
|
|
|
static void
|
2019-02-07 20:18:49 +00:00
|
|
|
|
on_page_page_notify (GtkWidget *widget,
|
|
|
|
|
GParamSpec *arg,
|
|
|
|
|
gpointer data)
|
2011-07-09 18:48:04 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (data);
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
|
|
|
|
{
|
|
|
|
|
update_buttons_state (assistant);
|
|
|
|
|
update_title_state (assistant);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
static void
|
|
|
|
|
on_page_notify (GtkAssistantPage *page,
|
|
|
|
|
GParamSpec *arg,
|
|
|
|
|
gpointer data)
|
|
|
|
|
{
|
|
|
|
|
if (page->page)
|
|
|
|
|
on_page_page_notify (page->page, arg, data);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-09 18:48:04 +00:00
|
|
|
|
static void
|
2015-10-05 12:19:07 +00:00
|
|
|
|
assistant_remove_page_cb (GtkContainer *container,
|
2015-06-15 01:04:15 +00:00
|
|
|
|
GtkWidget *page,
|
2011-07-09 18:48:04 +00:00
|
|
|
|
GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-07-09 18:48:04 +00:00
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *page_node;
|
|
|
|
|
GList *element;
|
|
|
|
|
|
|
|
|
|
element = find_page (assistant, page);
|
|
|
|
|
if (!element)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
page_info = element->data;
|
|
|
|
|
|
|
|
|
|
/* If this is the current page, we need to switch away. */
|
|
|
|
|
if (page_info == priv->current_page)
|
|
|
|
|
{
|
|
|
|
|
if (!compute_next_step (assistant))
|
|
|
|
|
{
|
|
|
|
|
/* The best we can do at this point is probably to pick
|
|
|
|
|
* the first visible page.
|
|
|
|
|
*/
|
|
|
|
|
page_node = priv->pages;
|
|
|
|
|
|
|
|
|
|
while (page_node &&
|
|
|
|
|
!gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
|
|
|
|
|
page_node = page_node->next;
|
|
|
|
|
|
|
|
|
|
if (page_node == element)
|
|
|
|
|
page_node = page_node->next;
|
|
|
|
|
|
|
|
|
|
if (page_node)
|
|
|
|
|
priv->current_page = page_node->data;
|
|
|
|
|
else
|
|
|
|
|
priv->current_page = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_signal_handlers_disconnect_by_func (page_info->page, on_page_page_notify, assistant);
|
|
|
|
|
g_signal_handlers_disconnect_by_func (page_info, on_page_notify, assistant);
|
2011-07-09 18:48:04 +00:00
|
|
|
|
|
|
|
|
|
gtk_size_group_remove_widget (priv->title_size_group, page_info->regular_title);
|
|
|
|
|
gtk_size_group_remove_widget (priv->title_size_group, page_info->current_title);
|
|
|
|
|
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->sidebar), page_info->regular_title);
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->sidebar), page_info->current_title);
|
|
|
|
|
|
|
|
|
|
priv->pages = g_list_remove_link (priv->pages, element);
|
|
|
|
|
priv->visited_pages = g_slist_remove_all (priv->visited_pages, page_info);
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_object_unref (page_info);
|
2011-07-09 18:48:04 +00:00
|
|
|
|
|
|
|
|
|
g_list_free_1 (element);
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
|
|
|
|
{
|
|
|
|
|
update_buttons_state (assistant);
|
|
|
|
|
update_actions_size (assistant);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_init (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2013-06-27 19:02:52 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
priv->pages = NULL;
|
|
|
|
|
priv->current_page = NULL;
|
|
|
|
|
priv->visited_pages = NULL;
|
|
|
|
|
|
|
|
|
|
priv->forward_function = default_forward_function;
|
|
|
|
|
priv->forward_function_data = assistant;
|
|
|
|
|
priv->forward_data_destroy = NULL;
|
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
g_object_get (gtk_widget_get_settings (GTK_WIDGET (assistant)),
|
|
|
|
|
"gtk-dialogs-use-header", &priv->use_header_bar,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2013-03-23 10:10:34 +00:00
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (assistant));
|
|
|
|
|
|
|
|
|
|
if (alternative_button_order (assistant))
|
|
|
|
|
{
|
|
|
|
|
GList *buttons, *l;
|
|
|
|
|
|
|
|
|
|
/* Reverse the action area children for the alternative button order setting */
|
|
|
|
|
buttons = gtk_container_get_children (GTK_CONTAINER (priv->action_area));
|
|
|
|
|
|
|
|
|
|
for (l = buttons; l; l = l->next)
|
2019-01-22 23:44:34 +00:00
|
|
|
|
gtk_box_reorder_child_after (GTK_BOX (priv->action_area), GTK_WIDGET (l->data), NULL);
|
2013-03-23 10:10:34 +00:00
|
|
|
|
|
|
|
|
|
g_list_free (buttons);
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-02-07 20:18:49 +00:00
|
|
|
|
gtk_assistant_page_set_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
const GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-02-07 20:18:49 +00:00
|
|
|
|
GtkAssistantPage *page = GTK_ASSISTANT_PAGE (object);
|
|
|
|
|
GtkWidget *assistant = NULL;
|
|
|
|
|
|
|
|
|
|
if (page->page)
|
|
|
|
|
assistant = gtk_widget_get_ancestor (page->page, GTK_TYPE_ASSISTANT);
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
2019-02-07 20:18:49 +00:00
|
|
|
|
case CHILD_PROP_CHILD:
|
|
|
|
|
g_set_object (&page->page, g_value_get_object (value));
|
|
|
|
|
break;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
case CHILD_PROP_PAGE_TYPE:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
if (page->type != g_value_get_enum (value))
|
|
|
|
|
{
|
|
|
|
|
page->type = g_value_get_enum (value);
|
|
|
|
|
|
|
|
|
|
/* backwards compatibility to the era before fixing bug 604289 */
|
|
|
|
|
if (page->type == GTK_ASSISTANT_PAGE_SUMMARY && !page->complete_set)
|
|
|
|
|
{
|
|
|
|
|
page->complete = TRUE;
|
|
|
|
|
page->complete_set = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Always set buttons state, a change in a future page
|
|
|
|
|
* might change current page buttons
|
|
|
|
|
*/
|
|
|
|
|
if (assistant)
|
|
|
|
|
update_buttons_state (GTK_ASSISTANT (assistant));
|
|
|
|
|
g_object_notify (G_OBJECT (page), "page-type");
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
case CHILD_PROP_PAGE_TITLE:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_free (page->title);
|
|
|
|
|
page->title = g_value_dup_string (value);
|
|
|
|
|
|
|
|
|
|
if (assistant)
|
|
|
|
|
{
|
|
|
|
|
gtk_label_set_text ((GtkLabel*) page->regular_title, page->title);
|
|
|
|
|
gtk_label_set_text ((GtkLabel*) page->current_title, page->title);
|
|
|
|
|
update_title_state (GTK_ASSISTANT (assistant));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (page), "title");
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
case CHILD_PROP_PAGE_COMPLETE:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
if (page->complete != g_value_get_boolean (value))
|
|
|
|
|
{
|
|
|
|
|
page->complete = g_value_get_boolean (value);
|
|
|
|
|
page->complete_set = TRUE;
|
|
|
|
|
|
|
|
|
|
/* Always set buttons state, a change in a future page
|
|
|
|
|
* might change current page buttons
|
|
|
|
|
*/
|
|
|
|
|
if (assistant)
|
|
|
|
|
update_buttons_state (GTK_ASSISTANT (assistant));
|
|
|
|
|
g_object_notify (G_OBJECT (page), "complete");
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
default:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-02-07 20:18:49 +00:00
|
|
|
|
gtk_assistant_page_get_property (GObject *object,
|
|
|
|
|
guint property_id,
|
|
|
|
|
GValue *value,
|
|
|
|
|
GParamSpec *pspec)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-02-07 20:18:49 +00:00
|
|
|
|
GtkAssistantPage *page = GTK_ASSISTANT_PAGE (object);
|
2011-11-08 03:56:36 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
switch (property_id)
|
|
|
|
|
{
|
2019-02-07 20:18:49 +00:00
|
|
|
|
case CHILD_PROP_CHILD:
|
|
|
|
|
g_value_set_object (value, page->page);
|
|
|
|
|
break;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
case CHILD_PROP_PAGE_TYPE:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_value_set_enum (value, page->type);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
case CHILD_PROP_PAGE_TITLE:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_value_set_string (value, page->title);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
case CHILD_PROP_PAGE_COMPLETE:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_value_set_boolean (value, page->complete);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
default:
|
2019-02-07 20:18:49 +00:00
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-09-18 23:55:42 +00:00
|
|
|
|
gtk_assistant_destroy (GtkWidget *widget)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2010-09-18 23:55:42 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
if (priv->model)
|
|
|
|
|
g_list_model_items_changed (G_LIST_MODEL (priv->model), 0, g_list_length (priv->pages), 0);
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
/* We set current to NULL so that the remove code doesn't try
|
|
|
|
|
* to do anything funny
|
|
|
|
|
*/
|
|
|
|
|
priv->current_page = NULL;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-07-09 18:48:04 +00:00
|
|
|
|
if (priv->content)
|
|
|
|
|
{
|
2019-02-14 19:07:46 +00:00
|
|
|
|
GList *children, *l;
|
2011-07-09 18:48:04 +00:00
|
|
|
|
|
2019-02-14 19:07:46 +00:00
|
|
|
|
children = gtk_container_get_children (GTK_CONTAINER (priv->content));
|
|
|
|
|
for (l = children; l; l = l->next)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *page = l->data;
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->content), page);
|
|
|
|
|
}
|
|
|
|
|
g_list_free (children);
|
2011-07-09 18:48:04 +00:00
|
|
|
|
|
|
|
|
|
/* Our GtkAssistantPage list should be empty now. */
|
|
|
|
|
g_warn_if_fail (priv->pages == NULL);
|
|
|
|
|
|
|
|
|
|
priv->content = NULL;
|
|
|
|
|
}
|
2011-04-17 00:45:26 +00:00
|
|
|
|
|
|
|
|
|
if (priv->sidebar)
|
|
|
|
|
priv->sidebar = NULL;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
if (priv->action_area)
|
2011-04-17 00:45:26 +00:00
|
|
|
|
priv->action_area = NULL;
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
if (priv->forward_function)
|
|
|
|
|
{
|
|
|
|
|
if (priv->forward_function_data &&
|
2011-01-24 02:50:39 +00:00
|
|
|
|
priv->forward_data_destroy)
|
|
|
|
|
priv->forward_data_destroy (priv->forward_function_data);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
priv->forward_function = NULL;
|
|
|
|
|
priv->forward_function_data = NULL;
|
|
|
|
|
priv->forward_data_destroy = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (priv->visited_pages)
|
|
|
|
|
{
|
|
|
|
|
g_slist_free (priv->visited_pages);
|
|
|
|
|
priv->visited_pages = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-27 17:57:58 +00:00
|
|
|
|
gtk_window_set_titlebar (GTK_WINDOW (widget), NULL);
|
2010-09-18 23:55:42 +00:00
|
|
|
|
GTK_WIDGET_CLASS (gtk_assistant_parent_class)->destroy (widget);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GList*
|
|
|
|
|
find_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GList *child = priv->pages;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
while (child)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info = child->data;
|
2019-02-14 19:46:01 +00:00
|
|
|
|
if (page_info->page == page)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
return child;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
child = child->next;
|
|
|
|
|
}
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_map (GtkWidget *widget)
|
|
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GList *page_node;
|
2009-07-17 02:06:40 +00:00
|
|
|
|
GtkAssistantPage *page;
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gint page_num;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
/* if there's no default page, pick the first one */
|
2009-07-17 02:06:40 +00:00
|
|
|
|
page = NULL;
|
2011-04-17 00:45:26 +00:00
|
|
|
|
page_num = 0;
|
2009-07-17 02:06:40 +00:00
|
|
|
|
if (!priv->current_page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
page_node = priv->pages;
|
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
|
while (page_node && !gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
|
2011-04-17 00:45:26 +00:00
|
|
|
|
{
|
|
|
|
|
page_node = page_node->next;
|
|
|
|
|
page_num++;
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
if (page_node)
|
2011-01-24 02:50:39 +00:00
|
|
|
|
page = page_node->data;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (page && gtk_widget_get_visible (page->page))
|
|
|
|
|
set_current_page (assistant, page_num);
|
|
|
|
|
|
|
|
|
|
update_buttons_state (assistant);
|
|
|
|
|
update_actions_size (assistant);
|
|
|
|
|
update_title_state (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_assistant_parent_class)->map (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_unmap (GtkWidget *widget)
|
|
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_slist_free (priv->visited_pages);
|
|
|
|
|
priv->visited_pages = NULL;
|
|
|
|
|
priv->current_page = NULL;
|
|
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_assistant_parent_class)->unmap (widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2018-01-01 20:24:16 +00:00
|
|
|
|
gtk_assistant_close_request (GtkWindow *window)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2018-01-01 20:24:16 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (window);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
/* Do not allow cancelling in the middle of a progress page */
|
|
|
|
|
if (priv->current_page &&
|
|
|
|
|
(priv->current_page->type != GTK_ASSISTANT_PAGE_PROGRESS ||
|
|
|
|
|
priv->current_page->complete))
|
2018-01-01 20:24:16 +00:00
|
|
|
|
g_signal_emit (assistant, signals [CANCEL], 0, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_add (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (container);
|
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
|
|
|
|
|
2013-03-23 10:10:34 +00:00
|
|
|
|
/* A bit tricky here, GtkAssistant doesnt exactly play by
|
|
|
|
|
* the rules by allowing gtk_container_add() to insert pages.
|
|
|
|
|
*
|
|
|
|
|
* For the first invocation (from the builder template invocation),
|
|
|
|
|
* let's make sure we add the actual direct container content properly.
|
|
|
|
|
*/
|
2019-05-27 01:20:53 +00:00
|
|
|
|
if (!priv->constructed)
|
2013-03-23 10:10:34 +00:00
|
|
|
|
{
|
2014-06-16 21:31:56 +00:00
|
|
|
|
gtk_widget_set_parent (page, GTK_WIDGET (container));
|
|
|
|
|
_gtk_bin_set_child (GTK_BIN (container), page);
|
2013-03-23 10:10:34 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gtk_assistant_append_page (GTK_ASSISTANT (container), page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_remove (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (container);
|
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-02-14 19:07:46 +00:00
|
|
|
|
/* Forward this removal to the content stack */
|
2019-05-27 01:20:53 +00:00
|
|
|
|
if (gtk_widget_get_parent (page) == priv->content)
|
2011-07-17 23:35:37 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->content), page);
|
2011-07-17 23:35:37 +00:00
|
|
|
|
}
|
2017-01-19 14:02:59 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GTK_CONTAINER_CLASS (gtk_assistant_parent_class)->remove (container, page);
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_new:
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* Creates a new #GtkAssistant.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: a newly created #GtkAssistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkWidget*
|
|
|
|
|
gtk_assistant_new (void)
|
|
|
|
|
{
|
|
|
|
|
GtkWidget *assistant;
|
|
|
|
|
|
2009-04-18 18:42:43 +00:00
|
|
|
|
assistant = g_object_new (GTK_TYPE_ASSISTANT, NULL);
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
return assistant;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_current_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
*
|
2011-04-17 00:45:26 +00:00
|
|
|
|
* Returns the page number of the current page.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: The index (starting from 0) of the current
|
2011-04-17 00:45:26 +00:00
|
|
|
|
* page in the @assistant, or -1 if the @assistant has no pages,
|
|
|
|
|
* or no current page.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_assistant_get_current_page (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), -1);
|
|
|
|
|
|
|
|
|
|
if (!priv->pages || !priv->current_page)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return g_list_index (priv->pages, priv->current_page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_set_current_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page_num: index of the page to switch to, starting from 0.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* If negative, the last page will be used. If greater
|
|
|
|
|
* than the number of pages in the @assistant, nothing
|
|
|
|
|
* will be done.
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* Switches the page to @page_num.
|
|
|
|
|
*
|
|
|
|
|
* Note that this will only be necessary in custom buttons,
|
|
|
|
|
* as the @assistant flow can be set with
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* gtk_assistant_set_forward_page_func().
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_set_current_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
gint page_num)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkAssistantPage *page;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
|
|
if (page_num >= 0)
|
|
|
|
|
page = (GtkAssistantPage *) g_list_nth_data (priv->pages, page_num);
|
|
|
|
|
else
|
2011-04-17 00:45:26 +00:00
|
|
|
|
{
|
|
|
|
|
page = (GtkAssistantPage *) g_list_last (priv->pages)->data;
|
|
|
|
|
page_num = g_list_length (priv->pages);
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (page != NULL);
|
|
|
|
|
|
|
|
|
|
if (priv->current_page == page)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
|
/* only add the page to the visited list if the assistant is mapped,
|
|
|
|
|
* if not, just use it as an initial page setting, for the cases where
|
|
|
|
|
* the initial page is != to 0
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*/
|
2010-03-02 04:19:28 +00:00
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
2008-04-11 17:08:21 +00:00
|
|
|
|
priv->visited_pages = g_slist_prepend (priv->visited_pages,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
priv->current_page);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
set_current_page (assistant, page_num);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-10-30 19:12:58 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_next_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* Navigate to the next page.
|
|
|
|
|
*
|
|
|
|
|
* It is a programming error to call this function when
|
|
|
|
|
* there is no next page.
|
2010-10-30 19:12:58 +00:00
|
|
|
|
*
|
|
|
|
|
* This function is for use when creating pages of the
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* #GTK_ASSISTANT_PAGE_CUSTOM type.
|
|
|
|
|
*/
|
2010-10-30 19:12:58 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_next_page (GtkAssistant *assistant)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
|
|
if (!compute_next_step (assistant))
|
2011-01-24 02:50:39 +00:00
|
|
|
|
g_critical ("Page flow is broken.\n"
|
|
|
|
|
"You may want to end it with a page of type\n"
|
|
|
|
|
"GTK_ASSISTANT_PAGE_CONFIRM or GTK_ASSISTANT_PAGE_SUMMARY");
|
2010-10-30 19:12:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_previous_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* Navigate to the previous visited page.
|
|
|
|
|
*
|
|
|
|
|
* It is a programming error to call this function when
|
|
|
|
|
* no previous page is available.
|
2010-10-30 19:12:58 +00:00
|
|
|
|
*
|
|
|
|
|
* This function is for use when creating pages of the
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* #GTK_ASSISTANT_PAGE_CUSTOM type.
|
|
|
|
|
*/
|
2010-10-30 19:12:58 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_previous_page (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2010-10-30 19:12:58 +00:00
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GSList *page_node;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
|
|
/* skip the progress pages when going back */
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
page_node = priv->visited_pages;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (page_node != NULL);
|
|
|
|
|
|
|
|
|
|
priv->visited_pages = priv->visited_pages->next;
|
|
|
|
|
page_info = (GtkAssistantPage *) page_node->data;
|
|
|
|
|
g_slist_free_1 (page_node);
|
|
|
|
|
}
|
|
|
|
|
while (page_info->type == GTK_ASSISTANT_PAGE_PROGRESS ||
|
2011-01-24 02:50:39 +00:00
|
|
|
|
!gtk_widget_get_visible (page_info->page));
|
2010-10-30 19:12:58 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
set_current_page (assistant, g_list_index (priv->pages, page_info));
|
2010-10-30 19:12:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_n_pages:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
*
|
|
|
|
|
* Returns the number of pages in the @assistant
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the number of pages in the @assistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_assistant_get_n_pages (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
|
|
|
|
|
|
|
|
|
|
return g_list_length (priv->pages);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_nth_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* @page_num: the index of a page in the @assistant,
|
|
|
|
|
* or -1 to get the last page
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the child widget contained in page number @page_num.
|
|
|
|
|
*
|
2015-12-28 20:14:08 +00:00
|
|
|
|
* Returns: (nullable) (transfer none): the child widget, or %NULL
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* if @page_num is out of bounds
|
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkWidget*
|
|
|
|
|
gtk_assistant_get_nth_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
gint page_num)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkAssistantPage *page;
|
|
|
|
|
GList *elem;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
|
2010-02-23 16:23:10 +00:00
|
|
|
|
g_return_val_if_fail (page_num >= -1, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2010-02-23 16:23:10 +00:00
|
|
|
|
if (page_num == -1)
|
|
|
|
|
elem = g_list_last (priv->pages);
|
|
|
|
|
else
|
|
|
|
|
elem = g_list_nth (priv->pages, page_num);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
if (!elem)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
page = (GtkAssistantPage *) elem->data;
|
|
|
|
|
|
|
|
|
|
return page->page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_prepend_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page: a #GtkWidget
|
|
|
|
|
*
|
|
|
|
|
* Prepends a page to the @assistant.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the index (starting at 0) of the inserted page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_assistant_prepend_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
|
|
|
|
|
|
|
|
|
|
return gtk_assistant_insert_page (assistant, page, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_append_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page: a #GtkWidget
|
|
|
|
|
*
|
|
|
|
|
* Appends a page to the @assistant.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the index (starting at 0) of the inserted page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_assistant_append_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
|
|
|
|
|
|
|
|
|
|
return gtk_assistant_insert_page (assistant, page, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_insert_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page: a #GtkWidget
|
|
|
|
|
* @position: the index (starting at 0) at which to insert the page,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* or -1 to append the page to the @assistant
|
2006-01-18 22:39:14 +00:00
|
|
|
|
*
|
|
|
|
|
* Inserts a page in the @assistant at a given position.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the index (starting from 0) of the inserted page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gint
|
|
|
|
|
gtk_assistant_insert_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page,
|
|
|
|
|
gint position)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
|
2010-08-11 21:18:32 +00:00
|
|
|
|
g_return_val_if_fail (gtk_widget_get_parent (page) == NULL, 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
page_info = g_object_new (GTK_TYPE_ASSISTANT_PAGE, NULL);
|
|
|
|
|
page_info->page = g_object_ref (page);
|
|
|
|
|
|
|
|
|
|
return gtk_assistant_add_page (assistant, page_info, position);
|
2019-02-08 14:49:54 +00:00
|
|
|
|
|
|
|
|
|
g_object_unref (page_info);
|
2019-02-07 20:18:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
gtk_assistant_add_page (GtkAssistant *assistant,
|
|
|
|
|
GtkAssistantPage *page_info,
|
|
|
|
|
gint position)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2019-02-07 20:18:49 +00:00
|
|
|
|
gint n_pages;
|
|
|
|
|
GtkStyleContext *context;
|
|
|
|
|
GtkWidget *sibling;
|
2019-02-14 19:07:46 +00:00
|
|
|
|
char *name;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
|
|
|
|
page_info->regular_title = gtk_label_new (page_info->title);
|
|
|
|
|
page_info->current_title = gtk_label_new (page_info->title);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2014-10-01 04:50:25 +00:00
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (page_info->regular_title), 0.0);
|
|
|
|
|
gtk_label_set_xalign (GTK_LABEL (page_info->current_title), 0.0);
|
2014-05-13 12:45:00 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_show (page_info->regular_title);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
gtk_widget_hide (page_info->current_title);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
context = gtk_widget_get_style_context (page_info->current_title);
|
2011-01-04 00:57:50 +00:00
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_size_group_add_widget (priv->title_size_group, page_info->regular_title);
|
|
|
|
|
gtk_size_group_add_widget (priv->title_size_group, page_info->current_title);
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_signal_connect (G_OBJECT (page_info->page), "notify::visible",
|
|
|
|
|
G_CALLBACK (on_page_page_notify), assistant);
|
2015-10-26 13:01:07 +00:00
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_signal_connect (G_OBJECT (page_info), "notify::page-title",
|
2015-10-26 13:01:07 +00:00
|
|
|
|
G_CALLBACK (on_page_notify), assistant);
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_signal_connect (G_OBJECT (page_info), "notify::page-type",
|
2015-10-26 13:01:07 +00:00
|
|
|
|
G_CALLBACK (on_page_notify), assistant);
|
2011-01-04 00:57:50 +00:00
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
n_pages = g_list_length (priv->pages);
|
|
|
|
|
|
|
|
|
|
if (position < 0 || position > n_pages)
|
|
|
|
|
position = n_pages;
|
|
|
|
|
|
2019-02-08 14:49:54 +00:00
|
|
|
|
priv->pages = g_list_insert (priv->pages, g_object_ref (page_info), position);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-01-22 23:44:34 +00:00
|
|
|
|
if (position == 0)
|
|
|
|
|
sibling = NULL;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
sibling = gtk_widget_get_first_child (priv->sidebar);
|
|
|
|
|
for (i = 1; i < 2 * position; i++)
|
|
|
|
|
sibling = gtk_widget_get_next_sibling (sibling);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->current_title, sibling);
|
|
|
|
|
gtk_box_insert_child_after (GTK_BOX (priv->sidebar), page_info->regular_title, sibling);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2019-02-14 19:46:01 +00:00
|
|
|
|
name = g_strdup_printf ("%p", page_info->page);
|
|
|
|
|
gtk_stack_add_named (GTK_STACK (priv->content), page_info->page, name);
|
2019-02-14 19:07:46 +00:00
|
|
|
|
g_free (name);
|
2011-04-17 00:45:26 +00:00
|
|
|
|
|
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2011-04-17 00:45:26 +00:00
|
|
|
|
update_buttons_state (assistant);
|
|
|
|
|
update_actions_size (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
if (priv->model)
|
|
|
|
|
g_list_model_items_changed (priv->model, position, 0, 1);
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
return position;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-12 01:46:38 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_remove_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page_num: the index of a page in the @assistant,
|
2011-09-13 08:08:22 +00:00
|
|
|
|
* or -1 to remove the last page
|
2011-07-12 01:46:38 +00:00
|
|
|
|
*
|
2014-02-07 18:01:26 +00:00
|
|
|
|
* Removes the @page_num’s page from @assistant.
|
2011-07-12 01:46:38 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gtk_assistant_remove_page (GtkAssistant *assistant,
|
|
|
|
|
gint page_num)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2011-07-12 01:46:38 +00:00
|
|
|
|
GtkWidget *page;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
|
|
page = gtk_assistant_get_nth_page (assistant, page_num);
|
|
|
|
|
|
|
|
|
|
if (page)
|
2011-07-14 09:36:29 +00:00
|
|
|
|
gtk_container_remove (GTK_CONTAINER (assistant), page);
|
2019-02-13 23:27:25 +00:00
|
|
|
|
|
2019-05-27 01:20:53 +00:00
|
|
|
|
if (priv->model)
|
|
|
|
|
g_list_model_items_changed (priv->model, page_num, 1, 0);
|
2011-07-12 01:46:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_set_forward_page_func:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* @page_func: (allow-none): the #GtkAssistantPageFunc, or %NULL
|
|
|
|
|
* to use the default one
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* @data: user data for @page_func
|
|
|
|
|
* @destroy: destroy notifier for @data
|
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* Sets the page forwarding function to be @page_func.
|
|
|
|
|
*
|
|
|
|
|
* This function will be used to determine what will be
|
|
|
|
|
* the next page when the user presses the forward button.
|
|
|
|
|
* Setting @page_func to %NULL will make the assistant to
|
|
|
|
|
* use the default forward function, which just goes to the
|
|
|
|
|
* next visible page.
|
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_set_forward_page_func (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkAssistantPageFunc page_func,
|
|
|
|
|
gpointer data,
|
|
|
|
|
GDestroyNotify destroy)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
|
|
if (priv->forward_data_destroy &&
|
|
|
|
|
priv->forward_function_data)
|
|
|
|
|
(*priv->forward_data_destroy) (priv->forward_function_data);
|
|
|
|
|
|
|
|
|
|
if (page_func)
|
|
|
|
|
{
|
|
|
|
|
priv->forward_function = page_func;
|
|
|
|
|
priv->forward_function_data = data;
|
|
|
|
|
priv->forward_data_destroy = destroy;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
priv->forward_function = default_forward_function;
|
|
|
|
|
priv->forward_function_data = assistant;
|
|
|
|
|
priv->forward_data_destroy = NULL;
|
|
|
|
|
}
|
2006-01-28 06:03:50 +00:00
|
|
|
|
|
|
|
|
|
/* Page flow has possibly changed, so the
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* buttons state might need to change too
|
|
|
|
|
*/
|
2011-04-17 00:45:26 +00:00
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
|
|
|
|
update_buttons_state (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
static void
|
|
|
|
|
add_to_action_area (GtkAssistant *assistant,
|
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
|
|
|
|
|
gtk_widget_set_valign (child, GTK_ALIGN_BASELINE);
|
|
|
|
|
|
2018-12-26 07:20:34 +00:00
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->action_area), child);
|
2014-01-29 02:27:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_add_action_widget:
|
2006-01-28 06:03:50 +00:00
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* @child: a #GtkWidget
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* Adds a widget to the action area of a #GtkAssistant.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_add_action_widget (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *child)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_BUTTON (child))
|
2011-04-17 00:45:26 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_size_group_add_widget (priv->button_size_group, child);
|
|
|
|
|
priv->extra_buttons += 1;
|
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
|
|
|
|
update_actions_size (assistant);
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
2014-01-29 02:27:26 +00:00
|
|
|
|
if (priv->constructed && priv->use_header_bar)
|
|
|
|
|
add_to_header_bar (assistant, child);
|
|
|
|
|
else
|
|
|
|
|
add_to_action_area (assistant, child);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_remove_action_widget:
|
2006-01-28 06:03:50 +00:00
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* @child: a #GtkWidget
|
|
|
|
|
*
|
|
|
|
|
* Removes a widget from the action area of a #GtkAssistant.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_remove_action_widget (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *child)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
|
|
|
|
|
|
|
|
|
if (GTK_IS_BUTTON (child))
|
2011-04-17 00:45:26 +00:00
|
|
|
|
{
|
|
|
|
|
gtk_size_group_remove_widget (priv->button_size_group, child);
|
|
|
|
|
priv->extra_buttons -= 1;
|
|
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
|
|
|
|
update_actions_size (assistant);
|
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->action_area), child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_set_page_title:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-07-17 03:43:29 +00:00
|
|
|
|
* @page: a page of @assistant
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* @title: the new title for @page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets a title for @page.
|
|
|
|
|
*
|
|
|
|
|
* The title is displayed in the header area of the assistant
|
|
|
|
|
* when @page is the current page.
|
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_set_page_title (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page,
|
|
|
|
|
const gchar *title)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (page));
|
|
|
|
|
|
|
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_object_set (page_info, "title", title, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_page_title:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page: a page of @assistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Gets the title for @page.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the title for @page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2011-06-06 18:13:44 +00:00
|
|
|
|
const gchar*
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gtk_assistant_get_page_title (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (page), NULL);
|
|
|
|
|
|
|
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (child != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
return page_info->title;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_set_page_type:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-07-17 03:43:29 +00:00
|
|
|
|
* @page: a page of @assistant
|
2006-01-18 22:39:14 +00:00
|
|
|
|
* @type: the new type for @page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets the page type for @page.
|
|
|
|
|
*
|
|
|
|
|
* The page type determines the page behavior in the @assistant.
|
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_set_page_type (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page,
|
|
|
|
|
GtkAssistantPageType type)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (page));
|
|
|
|
|
|
|
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_object_set (page_info, "page-type", type, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_page_type:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page: a page of @assistant
|
|
|
|
|
*
|
|
|
|
|
* Gets the page type of @page.
|
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: the page type of @page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
GtkAssistantPageType
|
|
|
|
|
gtk_assistant_get_page_type (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), GTK_ASSISTANT_PAGE_CONTENT);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (page), GTK_ASSISTANT_PAGE_CONTENT);
|
|
|
|
|
|
|
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (child != NULL, GTK_ASSISTANT_PAGE_CONTENT);
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
|
|
|
|
return page_info->type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_set_page_complete:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-07-17 03:43:29 +00:00
|
|
|
|
* @page: a page of @assistant
|
2006-01-28 06:03:50 +00:00
|
|
|
|
* @complete: the completeness status of the page
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
|
|
|
|
* Sets whether @page contents are complete.
|
|
|
|
|
*
|
|
|
|
|
* This will make @assistant update the buttons state
|
|
|
|
|
* to be able to continue the task.
|
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_set_page_complete (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page,
|
|
|
|
|
gboolean complete)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (page));
|
|
|
|
|
|
|
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
2019-02-07 20:18:49 +00:00
|
|
|
|
g_object_set (page_info, "complete", complete, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_page_complete:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @page: a page of @assistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
2009-05-30 06:14:03 +00:00
|
|
|
|
* Gets whether @page is complete.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
|
* Returns: %TRUE if @page is complete.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
|
gboolean
|
|
|
|
|
gtk_assistant_get_page_complete (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
GtkWidget *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), FALSE);
|
|
|
|
|
g_return_val_if_fail (GTK_IS_WIDGET (page), FALSE);
|
|
|
|
|
|
|
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (child != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
|
|
|
|
return page_info->complete;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-31 16:57:18 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_update_buttons_state:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
2006-01-31 16:57:18 +00:00
|
|
|
|
* Forces @assistant to recompute the buttons state.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*
|
|
|
|
|
* GTK+ automatically takes care of this in most situations,
|
2006-01-31 16:57:18 +00:00
|
|
|
|
* e.g. when the user goes to a different page, or when the
|
|
|
|
|
* visibility or completeness of a page changes.
|
|
|
|
|
*
|
|
|
|
|
* One situation where it can be necessary to call this
|
|
|
|
|
* function is when changing a value on the current page
|
|
|
|
|
* affects the future page flow of the assistant.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2006-01-31 16:57:18 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_update_buttons_state (GtkAssistant *assistant)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
update_buttons_state (assistant);
|
2006-01-31 16:57:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-06-02 20:00:16 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_commit:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
*
|
|
|
|
|
* Erases the visited page history so the back button is not
|
|
|
|
|
* shown on the current page, and removes the cancel button
|
|
|
|
|
* from subsequent pages.
|
|
|
|
|
*
|
|
|
|
|
* Use this when the information provided up to the current
|
|
|
|
|
* page is hereafter deemed permanent and cannot be modified
|
2011-01-24 02:50:39 +00:00
|
|
|
|
* or undone. For example, showing a progress page to track
|
2010-06-02 20:00:16 +00:00
|
|
|
|
* a long-running, unreversible operation after the user has
|
|
|
|
|
* clicked apply on a confirmation page.
|
2011-01-24 02:50:39 +00:00
|
|
|
|
*/
|
2010-06-02 20:00:16 +00:00
|
|
|
|
void
|
|
|
|
|
gtk_assistant_commit (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
|
|
|
|
|
2010-06-02 20:00:16 +00:00
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
2019-05-27 01:20:53 +00:00
|
|
|
|
g_slist_free (priv->visited_pages);
|
|
|
|
|
priv->visited_pages = NULL;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2019-05-27 01:20:53 +00:00
|
|
|
|
priv->committed = TRUE;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
2011-04-17 00:45:26 +00:00
|
|
|
|
update_buttons_state (assistant);
|
2010-06-02 20:00:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-06-12 03:53:19 +00:00
|
|
|
|
/* accessible implementation */
|
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
|
/* dummy typedefs */
|
2011-07-04 01:34:54 +00:00
|
|
|
|
typedef GtkWindowAccessible GtkAssistantAccessible;
|
|
|
|
|
typedef GtkWindowAccessibleClass GtkAssistantAccessibleClass;
|
2010-11-29 15:40:29 +00:00
|
|
|
|
|
2011-07-04 01:34:54 +00:00
|
|
|
|
G_DEFINE_TYPE (GtkAssistantAccessible, _gtk_assistant_accessible, GTK_TYPE_WINDOW_ACCESSIBLE);
|
2010-11-29 15:40:29 +00:00
|
|
|
|
|
2006-06-12 03:53:19 +00:00
|
|
|
|
static gint
|
|
|
|
|
gtk_assistant_accessible_get_n_children (AtkObject *accessible)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv;
|
2006-06-12 03:53:19 +00:00
|
|
|
|
GtkWidget *widget;
|
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
2010-11-29 15:40:29 +00:00
|
|
|
|
if (widget == NULL)
|
2006-06-12 03:53:19 +00:00
|
|
|
|
return 0;
|
|
|
|
|
|
2019-05-27 01:20:53 +00:00
|
|
|
|
priv = gtk_assistant_get_instance_private (GTK_ASSISTANT (widget));
|
|
|
|
|
|
|
|
|
|
return g_list_length (priv->pages) + 2;
|
2006-06-12 03:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static AtkObject *
|
|
|
|
|
gtk_assistant_accessible_ref_child (AtkObject *accessible,
|
2011-01-24 02:50:39 +00:00
|
|
|
|
gint index)
|
2006-06-12 03:53:19 +00:00
|
|
|
|
{
|
|
|
|
|
GtkAssistant *assistant;
|
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
|
GtkWidget *widget, *child;
|
|
|
|
|
gint n_pages;
|
|
|
|
|
AtkObject *obj;
|
2009-04-18 05:23:20 +00:00
|
|
|
|
const gchar *title;
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
2010-05-22 23:55:33 +00:00
|
|
|
|
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
|
2010-11-29 15:40:29 +00:00
|
|
|
|
if (widget == NULL)
|
2006-06-12 03:53:19 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
assistant = GTK_ASSISTANT (widget);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
priv = gtk_assistant_get_instance_private (assistant);
|
2006-06-12 03:53:19 +00:00
|
|
|
|
n_pages = g_list_length (priv->pages);
|
|
|
|
|
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return NULL;
|
|
|
|
|
else if (index < n_pages)
|
|
|
|
|
{
|
2009-05-29 10:50:00 +00:00
|
|
|
|
GtkAssistantPage *page = g_list_nth_data (priv->pages, index);
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
|
|
|
|
child = page->page;
|
2009-02-17 05:49:17 +00:00
|
|
|
|
title = gtk_assistant_get_page_title (assistant, child);
|
2006-06-12 03:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
else if (index == n_pages)
|
|
|
|
|
{
|
|
|
|
|
child = priv->action_area;
|
2009-02-17 05:49:17 +00:00
|
|
|
|
title = NULL;
|
2006-06-12 03:53:19 +00:00
|
|
|
|
}
|
2014-04-10 21:22:46 +00:00
|
|
|
|
else if (index == n_pages + 1)
|
|
|
|
|
{
|
|
|
|
|
child = priv->headerbar;
|
|
|
|
|
title = NULL;
|
|
|
|
|
}
|
2006-06-12 03:53:19 +00:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
2011-01-24 02:50:39 +00:00
|
|
|
|
|
2006-06-12 03:53:19 +00:00
|
|
|
|
obj = gtk_widget_get_accessible (child);
|
|
|
|
|
|
2009-02-17 05:49:17 +00:00
|
|
|
|
if (title)
|
|
|
|
|
atk_object_set_name (obj, title);
|
|
|
|
|
|
2006-06-12 03:53:19 +00:00
|
|
|
|
return g_object_ref (obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-12-05 17:18:30 +00:00
|
|
|
|
_gtk_assistant_accessible_class_init (GtkAssistantAccessibleClass *klass)
|
2006-06-12 03:53:19 +00:00
|
|
|
|
{
|
2010-11-29 15:40:29 +00:00
|
|
|
|
AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
|
atk_class->get_n_children = gtk_assistant_accessible_get_n_children;
|
|
|
|
|
atk_class->ref_child = gtk_assistant_accessible_ref_child;
|
2006-06-12 03:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
|
static void
|
2010-12-05 17:18:30 +00:00
|
|
|
|
_gtk_assistant_accessible_init (GtkAssistantAccessible *self)
|
2006-06-12 03:53:19 +00:00
|
|
|
|
{
|
2010-11-29 15:40:29 +00:00
|
|
|
|
}
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
|
/* buildable implementation */
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
2009-04-18 05:23:20 +00:00
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
iface->custom_tag_start = gtk_assistant_buildable_custom_tag_start;
|
|
|
|
|
iface->custom_finished = gtk_assistant_buildable_custom_finished;
|
2019-02-07 20:18:49 +00:00
|
|
|
|
iface->add_child = gtk_assistant_buildable_add_child;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const char *type)
|
|
|
|
|
{
|
|
|
|
|
if (GTK_IS_ASSISTANT_PAGE (child))
|
|
|
|
|
gtk_assistant_add_page (GTK_ASSISTANT (buildable), GTK_ASSISTANT_PAGE (child), -1);
|
|
|
|
|
else if (type && g_str_equal (type, "titlebar"))
|
|
|
|
|
{
|
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (buildable);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
|
|
|
|
priv->headerbar = GTK_WIDGET (child);
|
|
|
|
|
gtk_window_set_titlebar (GTK_WINDOW (buildable), priv->headerbar);
|
2019-02-07 20:18:49 +00:00
|
|
|
|
}
|
|
|
|
|
else if (GTK_IS_WIDGET (child))
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
|
|
|
|
|
else
|
|
|
|
|
g_warning ("Can't add a child of type '%s' to '%s'", G_OBJECT_TYPE_NAME (child), G_OBJECT_TYPE_NAME (buildable));
|
2009-04-18 05:23:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *tagname,
|
2019-08-29 13:21:20 +00:00
|
|
|
|
GtkBuildableParser *parser,
|
2009-04-18 05:23:20 +00:00
|
|
|
|
gpointer *data)
|
|
|
|
|
{
|
|
|
|
|
return parent_buildable_iface->custom_tag_start (buildable, builder, child,
|
|
|
|
|
tagname, parser, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
|
GtkBuilder *builder,
|
|
|
|
|
GObject *child,
|
|
|
|
|
const gchar *tagname,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
parent_buildable_iface->custom_finished (buildable, builder, child,
|
|
|
|
|
tagname, user_data);
|
|
|
|
|
}
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_page:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
* @child: a child of @assistant
|
|
|
|
|
*
|
|
|
|
|
* Returns the #GtkAssistantPage object for @child.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the #GtkAssistantPage for @child
|
|
|
|
|
*/
|
|
|
|
|
GtkAssistantPage *
|
|
|
|
|
gtk_assistant_get_page (GtkAssistant *assistant,
|
|
|
|
|
GtkWidget *child)
|
|
|
|
|
{
|
|
|
|
|
GList *page_info = find_page (assistant, child);
|
|
|
|
|
return (GtkAssistantPage *) (page_info ? page_info->data : NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_page_get_child:
|
|
|
|
|
* @page: a #GtkAssistantPage
|
|
|
|
|
*
|
|
|
|
|
* Returns the child to which @page belongs.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the child to which @page belongs
|
|
|
|
|
*/
|
|
|
|
|
GtkWidget *
|
|
|
|
|
gtk_assistant_page_get_child (GtkAssistantPage *page)
|
|
|
|
|
{
|
|
|
|
|
return page->page;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
#define GTK_TYPE_ASSISTANT_PAGES (gtk_assistant_pages_get_type ())
|
|
|
|
|
G_DECLARE_FINAL_TYPE (GtkAssistantPages, gtk_assistant_pages, GTK, ASSISTANT_PAGES, GObject)
|
|
|
|
|
|
|
|
|
|
struct _GtkAssistantPages
|
|
|
|
|
{
|
|
|
|
|
GObject parent_instance;
|
|
|
|
|
GtkAssistant *assistant;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct _GtkAssistantPagesClass
|
|
|
|
|
{
|
|
|
|
|
GObjectClass parent_class;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static GType
|
|
|
|
|
gtk_assistant_pages_get_item_type (GListModel *model)
|
|
|
|
|
{
|
|
|
|
|
return GTK_TYPE_ASSISTANT_PAGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static guint
|
|
|
|
|
gtk_assistant_pages_get_n_items (GListModel *model)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistantPages *pages = GTK_ASSISTANT_PAGES (model);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (pages->assistant);
|
2019-02-13 23:27:25 +00:00
|
|
|
|
|
2019-05-27 01:20:53 +00:00
|
|
|
|
return g_list_length (priv->pages);
|
2019-02-13 23:27:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gpointer
|
|
|
|
|
gtk_assistant_pages_get_item (GListModel *model,
|
|
|
|
|
guint position)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistantPages *pages = GTK_ASSISTANT_PAGES (model);
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (pages->assistant);
|
2019-02-13 23:27:25 +00:00
|
|
|
|
GtkAssistantPage *page;
|
|
|
|
|
|
2019-05-27 01:20:53 +00:00
|
|
|
|
page = g_list_nth_data (priv->pages, position);
|
2019-02-13 23:27:25 +00:00
|
|
|
|
|
|
|
|
|
return g_object_ref (page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_pages_list_model_init (GListModelInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_item_type = gtk_assistant_pages_get_item_type;
|
|
|
|
|
iface->get_n_items = gtk_assistant_pages_get_n_items;
|
|
|
|
|
iface->get_item = gtk_assistant_pages_get_item;
|
|
|
|
|
}
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkAssistantPages, gtk_assistant_pages, G_TYPE_OBJECT,
|
|
|
|
|
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_assistant_pages_list_model_init))
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_pages_init (GtkAssistantPages *pages)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gtk_assistant_pages_class_init (GtkAssistantPagesClass *class)
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-02-07 20:18:49 +00:00
|
|
|
|
|
2019-02-13 23:27:25 +00:00
|
|
|
|
static GtkAssistantPages *
|
|
|
|
|
gtk_assistant_pages_new (GtkAssistant *assistant)
|
|
|
|
|
{
|
|
|
|
|
GtkAssistantPages *pages;
|
|
|
|
|
|
|
|
|
|
pages = g_object_new (GTK_TYPE_ASSISTANT_PAGES, NULL);
|
|
|
|
|
pages->assistant = assistant;
|
|
|
|
|
|
|
|
|
|
return pages;
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-14 19:29:54 +00:00
|
|
|
|
/**
|
|
|
|
|
* gtk_assistant_get_pages:
|
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
|
*
|
|
|
|
|
* Gets a list model of the assistant pages.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): A list model of the pages.
|
|
|
|
|
*/
|
2019-02-13 23:27:25 +00:00
|
|
|
|
GListModel *
|
|
|
|
|
gtk_assistant_get_pages (GtkAssistant *assistant)
|
|
|
|
|
{
|
2019-05-27 01:20:53 +00:00
|
|
|
|
GtkAssistantPrivate *priv = gtk_assistant_get_instance_private (assistant);
|
2019-02-13 23:27:25 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), NULL);
|
|
|
|
|
|
|
|
|
|
if (priv->model)
|
|
|
|
|
return g_object_ref (priv->model);
|
|
|
|
|
|
|
|
|
|
priv->model = G_LIST_MODEL (gtk_assistant_pages_new (assistant));
|
|
|
|
|
|
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (priv->model), (gpointer *)&priv->model);
|
|
|
|
|
|
|
|
|
|
return priv->model;
|
|
|
|
|
}
|