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
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
* operation splitted in several steps, guiding the user through its pages
|
|
|
|
* and controlling the page flow to collect the necessary data.
|
|
|
|
*
|
2010-10-31 01:25:21 +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 and
|
|
|
|
* the <link linkend="GtkAssistantPageType">type</link> of each page, in
|
|
|
|
* addition to state information like the page
|
|
|
|
* <link linkend="gtk-assistant-set-page-complete">completion</link> and
|
|
|
|
* <link linkend="gtk-assistant-commit">committed</link> status.
|
|
|
|
*
|
2010-10-31 18:34:35 +00:00
|
|
|
* If you have a case that doesn't quite fit in #GtkAssistants way of
|
|
|
|
* handling buttons, you can use the #GTK_ASSISTANT_PAGE_CUSTOM page type
|
|
|
|
* and handle buttons yourself.
|
|
|
|
*
|
2010-03-05 22:44:31 +00:00
|
|
|
* <refsect2 id="GtkAssistant-BUILDER-UI">
|
|
|
|
* <title>GtkAssistant as GtkBuildable</title>
|
|
|
|
* <para>
|
|
|
|
* The GtkAssistant implementation of the GtkBuildable interface exposes the
|
|
|
|
* @action_area as internal children with the name "action_area".
|
|
|
|
*
|
|
|
|
* To add pages to an assistant in GtkBuilder, simply add it as a
|
|
|
|
* <child> to the GtkAssistant object, and set its child properties
|
|
|
|
* as necessary.
|
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2006-06-12 03:53:19 +00:00
|
|
|
#include <atk/atk.h>
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
#include "gtkassistant.h"
|
|
|
|
|
2011-02-17 17:35:07 +00:00
|
|
|
#include "gtkaccessibleprivate.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
#include "gtkbutton.h"
|
|
|
|
#include "gtkhbox.h"
|
2006-01-23 19:11:40 +00:00
|
|
|
#include "gtkhbbox.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
#include "gtkimage.h"
|
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtksizegroup.h"
|
2010-09-09 13:35:58 +00:00
|
|
|
#include "gtksizerequest.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
#include "gtkstock.h"
|
2011-01-04 19:51:19 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkprivate.h"
|
2009-04-18 05:23:20 +00:00
|
|
|
#include "gtkbuildable.h"
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define HEADER_SPACING 12
|
2006-01-30 15:51:54 +00:00
|
|
|
#define ACTION_AREA_SPACING 12
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
typedef struct _GtkAssistantPage GtkAssistantPage;
|
|
|
|
|
|
|
|
struct _GtkAssistantPage
|
|
|
|
{
|
|
|
|
GtkWidget *page;
|
|
|
|
GtkAssistantPageType type;
|
2009-12-10 16:34:29 +00:00
|
|
|
guint complete : 1;
|
|
|
|
guint complete_set : 1;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
GtkWidget *title;
|
|
|
|
GdkPixbuf *header_image;
|
|
|
|
GdkPixbuf *sidebar_image;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GtkAssistantPrivate
|
|
|
|
{
|
2010-05-24 13:46:51 +00:00
|
|
|
GtkWidget *cancel;
|
|
|
|
GtkWidget *forward;
|
|
|
|
GtkWidget *back;
|
|
|
|
GtkWidget *apply;
|
|
|
|
GtkWidget *close;
|
|
|
|
GtkWidget *last;
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
GtkWidget *header_image;
|
|
|
|
GtkWidget *sidebar_image;
|
|
|
|
|
|
|
|
GtkWidget *action_area;
|
|
|
|
|
|
|
|
GList *pages;
|
|
|
|
|
|
|
|
GtkAssistantPage *current_page;
|
|
|
|
|
|
|
|
GSList *visited_pages;
|
|
|
|
|
|
|
|
GtkSizeGroup *size_group;
|
|
|
|
|
|
|
|
GtkAssistantPageFunc forward_function;
|
|
|
|
gpointer forward_function_data;
|
|
|
|
GDestroyNotify forward_data_destroy;
|
2010-06-02 20:00:16 +00:00
|
|
|
|
|
|
|
guint committed : 1;
|
2006-01-18 22:39:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void gtk_assistant_class_init (GtkAssistantClass *class);
|
|
|
|
static void gtk_assistant_init (GtkAssistant *assistant);
|
2010-09-18 23:55:42 +00:00
|
|
|
static void gtk_assistant_destroy (GtkWidget *widget);
|
2011-01-04 00:57:50 +00:00
|
|
|
static void gtk_assistant_style_updated (GtkWidget *widget);
|
2010-10-27 00:57:23 +00:00
|
|
|
static void gtk_assistant_get_preferred_width (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural);
|
|
|
|
static void gtk_assistant_get_preferred_height (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural);
|
2006-01-18 22:39:14 +00:00
|
|
|
static void gtk_assistant_size_allocate (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkAllocation *allocation);
|
2006-01-18 22:39:14 +00:00
|
|
|
static void gtk_assistant_map (GtkWidget *widget);
|
|
|
|
static void gtk_assistant_unmap (GtkWidget *widget);
|
|
|
|
static gboolean gtk_assistant_delete_event (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GdkEventAny *event);
|
2010-09-08 14:37:43 +00:00
|
|
|
static gboolean gtk_assistant_draw (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
cairo_t *cr);
|
2006-01-28 06:03:50 +00:00
|
|
|
static gboolean gtk_assistant_focus (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkDirectionType direction);
|
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);
|
2006-01-18 22:39:14 +00:00
|
|
|
static void gtk_assistant_forall (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data);
|
2006-01-18 22:39:14 +00:00
|
|
|
static void gtk_assistant_set_child_property (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *child,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2006-01-18 22:39:14 +00:00
|
|
|
static void gtk_assistant_get_child_property (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *child,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2006-06-12 03:53:19 +00:00
|
|
|
static AtkObject *gtk_assistant_get_accessible (GtkWidget *widget);
|
2010-11-29 15:40:29 +00:00
|
|
|
static GType gtk_assistant_accessible_factory_get_type (void);
|
2006-06-12 03:53:19 +00:00
|
|
|
|
2009-04-18 05:23:20 +00:00
|
|
|
static void gtk_assistant_buildable_interface_init (GtkBuildableIface *iface);
|
|
|
|
static GObject *gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const gchar *childname);
|
|
|
|
static gboolean gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
GMarkupParser *parser,
|
|
|
|
gpointer *data);
|
|
|
|
static void gtk_assistant_buildable_custom_finished (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
gpointer user_data);
|
|
|
|
|
2009-12-10 16:34:29 +00:00
|
|
|
static GList* find_page (GtkAssistant *assistant,
|
|
|
|
GtkWidget *page);
|
2009-04-18 05:23:20 +00:00
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CHILD_PROP_0,
|
|
|
|
CHILD_PROP_PAGE_TYPE,
|
|
|
|
CHILD_PROP_PAGE_TITLE,
|
|
|
|
CHILD_PROP_PAGE_HEADER_IMAGE,
|
|
|
|
CHILD_PROP_PAGE_SIDEBAR_IMAGE,
|
|
|
|
CHILD_PROP_PAGE_COMPLETE
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CANCEL,
|
|
|
|
PREPARE,
|
|
|
|
APPLY,
|
|
|
|
CLOSE,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
gtk_assistant_buildable_interface_init))
|
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;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) class;
|
|
|
|
widget_class = (GtkWidgetClass *) class;
|
|
|
|
container_class = (GtkContainerClass *) class;
|
|
|
|
|
2010-09-18 23:55:42 +00:00
|
|
|
widget_class->destroy = gtk_assistant_destroy;
|
2011-01-04 00:57:50 +00:00
|
|
|
widget_class->style_updated = gtk_assistant_style_updated;
|
2010-10-27 00:57:23 +00:00
|
|
|
widget_class->get_preferred_width = gtk_assistant_get_preferred_width;
|
|
|
|
widget_class->get_preferred_height = gtk_assistant_get_preferred_height;
|
2006-01-18 22:39:14 +00:00
|
|
|
widget_class->size_allocate = gtk_assistant_size_allocate;
|
|
|
|
widget_class->map = gtk_assistant_map;
|
|
|
|
widget_class->unmap = gtk_assistant_unmap;
|
|
|
|
widget_class->delete_event = gtk_assistant_delete_event;
|
2010-09-08 14:37:43 +00:00
|
|
|
widget_class->draw = gtk_assistant_draw;
|
2006-01-28 06:03:50 +00:00
|
|
|
widget_class->focus = gtk_assistant_focus;
|
2006-06-12 03:53:19 +00:00
|
|
|
widget_class->get_accessible = gtk_assistant_get_accessible;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
container_class->add = gtk_assistant_add;
|
|
|
|
container_class->remove = gtk_assistant_remove;
|
|
|
|
container_class->forall = gtk_assistant_forall;
|
|
|
|
container_class->set_child_property = gtk_assistant_set_child_property;
|
|
|
|
container_class->get_child_property = gtk_assistant_get_child_property;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkAssistant::cancel:
|
|
|
|
* @assistant: the #GtkAssistant
|
|
|
|
*
|
|
|
|
* The ::cancel signal is emitted when then the cancel button is clicked.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
/**
|
|
|
|
* GtkAssistant::prepare:
|
|
|
|
* @assistant: the #GtkAssistant
|
|
|
|
* @page: the current page
|
|
|
|
*
|
2009-05-30 06:14:03 +00:00
|
|
|
* The ::prepare signal is emitted when a new page is set as the assistant's
|
2009-04-18 05:23:20 +00:00
|
|
|
* current page, before making the new page visible. A handler for this signal
|
2006-01-18 22:39:14 +00:00
|
|
|
* can do any preparation which are necessary before showing @page.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
g_cclosure_marshal_VOID__OBJECT,
|
|
|
|
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
|
|
|
*
|
|
|
|
* The ::apply signal is emitted when the apply button is clicked. The default
|
2009-05-30 06:14:03 +00:00
|
|
|
* 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
|
|
|
*
|
2009-05-30 06:14:03 +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,
|
2010-06-02 20:00:16 +00:00
|
|
|
* you might consider putting a page of type %GTK_ASSISTANT_PAGE_PROGRESS
|
2009-05-30 06:14:03 +00:00
|
|
|
* 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
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
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
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
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,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_param_spec_int ("header-padding",
|
|
|
|
P_("Header Padding"),
|
|
|
|
P_("Number of pixels around the header."),
|
|
|
|
0,
|
|
|
|
G_MAXINT,
|
|
|
|
6,
|
|
|
|
GTK_PARAM_READABLE));
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_class_install_style_property (widget_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_param_spec_int ("content-padding",
|
|
|
|
P_("Content Padding"),
|
|
|
|
P_("Number of pixels around the content pages."),
|
|
|
|
0,
|
|
|
|
G_MAXINT,
|
|
|
|
1,
|
|
|
|
GTK_PARAM_READABLE));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkAssistant:page-type:
|
|
|
|
*
|
2009-05-30 06:14:03 +00:00
|
|
|
* The type of the assistant page.
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
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,
|
|
|
|
GTK_PARAM_READWRITE));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkAssistant:title:
|
|
|
|
*
|
2009-05-30 06:14:03 +00:00
|
|
|
* The title that is displayed in the page header.
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* If title and header-image are both %NULL, no header is displayed.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
CHILD_PROP_PAGE_TITLE,
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
P_("Page title"),
|
|
|
|
P_("The title of the assistant page"),
|
|
|
|
NULL,
|
|
|
|
GTK_PARAM_READWRITE));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkAssistant:header-image:
|
|
|
|
*
|
|
|
|
* The image that is displayed next to the title in the page header.
|
|
|
|
*
|
|
|
|
* If title and header-image are both %NULL, no header is displayed.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
CHILD_PROP_PAGE_HEADER_IMAGE,
|
|
|
|
g_param_spec_object ("header-image",
|
|
|
|
P_("Header image"),
|
|
|
|
P_("Header image for the assistant page"),
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
GTK_PARAM_READWRITE));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* GtkAssistant:header-image:
|
|
|
|
*
|
2009-05-30 06:14:03 +00:00
|
|
|
* The image that is displayed next to the page.
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Set this to %NULL to make the sidebar disappear.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
|
|
|
*/
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
CHILD_PROP_PAGE_SIDEBAR_IMAGE,
|
|
|
|
g_param_spec_object ("sidebar-image",
|
|
|
|
P_("Sidebar image"),
|
|
|
|
P_("Sidebar image for the assistant page"),
|
|
|
|
GDK_TYPE_PIXBUF,
|
|
|
|
GTK_PARAM_READWRITE));
|
2006-01-18 22:39:14 +00:00
|
|
|
/**
|
|
|
|
* GtkAssistant:complete:
|
|
|
|
*
|
|
|
|
* Setting the "complete" child 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.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_container_class_install_child_property (container_class,
|
2011-01-24 02:50:39 +00:00
|
|
|
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,
|
|
|
|
G_PARAM_READWRITE));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
g_type_class_add_private (gobject_class, sizeof (GtkAssistantPrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
default_forward_function (gint current_page, gpointer data)
|
|
|
|
{
|
|
|
|
GtkAssistant *assistant;
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
GList *page_node;
|
|
|
|
|
|
|
|
assistant = GTK_ASSISTANT (data);
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
compute_last_button_state (GtkAssistant *assistant)
|
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-28 06:03:50 +00:00
|
|
|
GtkAssistantPage *page_info, *current_page_info;
|
2006-01-18 22:39:14 +00:00
|
|
|
gint count, page_num, n_pages;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
page_num = gtk_assistant_get_current_page (assistant);
|
|
|
|
n_pages = gtk_assistant_get_n_pages (assistant);
|
2006-01-28 06:03:50 +00:00
|
|
|
current_page_info = page_info = g_list_nth_data (priv->pages, page_num);
|
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++;
|
|
|
|
}
|
|
|
|
|
2006-01-23 19:11:40 +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))
|
2006-01-28 06:03:50 +00:00
|
|
|
{
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_widget_show (priv->last);
|
|
|
|
gtk_widget_set_sensitive (priv->last,
|
2011-01-24 02:50:39 +00:00
|
|
|
current_page_info->complete);
|
2006-01-28 06:03:50 +00:00
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
else
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_widget_hide (priv->last);
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
|
2010-06-02 20:00:16 +00:00
|
|
|
static void
|
|
|
|
compute_progress_state (GtkAssistant *assistant)
|
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
|
|
|
gint page_num, n_pages;
|
|
|
|
|
|
|
|
n_pages = gtk_assistant_get_n_pages (assistant);
|
|
|
|
page_num = gtk_assistant_get_current_page (assistant);
|
|
|
|
|
|
|
|
page_num = (priv->forward_function) (page_num, priv->forward_function_data);
|
|
|
|
|
|
|
|
if (page_num >= 0 && page_num < n_pages)
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_widget_show (priv->forward);
|
2010-06-02 20:00:16 +00:00
|
|
|
else
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_widget_hide (priv->forward);
|
2010-06-02 20:00:16 +00:00
|
|
|
}
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
static void
|
2006-01-31 16:57:18 +00:00
|
|
|
set_assistant_header_image (GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->header_image),
|
2011-01-24 02:50:39 +00:00
|
|
|
priv->current_page->header_image);
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-31 16:57:18 +00:00
|
|
|
set_assistant_sidebar_image (GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->sidebar_image),
|
2011-01-24 02:50:39 +00:00
|
|
|
priv->current_page->sidebar_image);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (priv->current_page->sidebar_image)
|
|
|
|
gtk_widget_show (priv->sidebar_image);
|
|
|
|
else
|
|
|
|
gtk_widget_hide (priv->sidebar_image);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-31 16:57:18 +00:00
|
|
|
set_assistant_buttons_state (GtkAssistant *assistant)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
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);
|
|
|
|
gtk_widget_grab_default (priv->forward);
|
|
|
|
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);
|
|
|
|
gtk_widget_grab_default (priv->apply);
|
|
|
|
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);
|
|
|
|
gtk_widget_grab_default (priv->forward);
|
|
|
|
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);
|
|
|
|
gtk_widget_grab_default (priv->close);
|
|
|
|
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);
|
|
|
|
gtk_widget_grab_default (priv->forward);
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-01-31 16:57:18 +00:00
|
|
|
set_current_page (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkAssistantPage *page)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
GtkAssistantPage *old_page;
|
|
|
|
|
|
|
|
if (priv->current_page &&
|
2010-01-07 15:47:35 +00:00
|
|
|
gtk_widget_is_drawable (priv->current_page->page))
|
2006-01-18 22:39:14 +00:00
|
|
|
old_page = priv->current_page;
|
|
|
|
else
|
|
|
|
old_page = NULL;
|
|
|
|
|
|
|
|
priv->current_page = page;
|
|
|
|
|
2006-01-31 16:57:18 +00:00
|
|
|
set_assistant_buttons_state (assistant);
|
|
|
|
set_assistant_header_image (assistant);
|
|
|
|
set_assistant_sidebar_image (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
g_signal_emit (assistant, signals [PREPARE], 0, priv->current_page->page);
|
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
if (gtk_widget_get_visible (priv->current_page->page) &&
|
|
|
|
gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-30 04:53:53 +00:00
|
|
|
gtk_widget_set_child_visible (priv->current_page->page, TRUE);
|
2011-01-21 03:39:20 +00:00
|
|
|
gtk_widget_set_child_visible (priv->current_page->title, TRUE);
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_map (priv->current_page->page);
|
|
|
|
gtk_widget_map (priv->current_page->title);
|
|
|
|
}
|
2011-01-24 02:50:39 +00:00
|
|
|
|
2010-03-02 04:19:28 +00:00
|
|
|
if (old_page && gtk_widget_get_mapped (old_page->page))
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-30 04:53:53 +00:00
|
|
|
gtk_widget_set_child_visible (old_page->page, FALSE);
|
2011-01-21 03:39:20 +00:00
|
|
|
gtk_widget_set_child_visible (old_page->title, FALSE);
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_unmap (old_page->page);
|
|
|
|
gtk_widget_unmap (old_page->title);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (assistant));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
compute_next_step (GtkAssistant *assistant)
|
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
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);
|
2006-01-31 16:57:18 +00:00
|
|
|
set_current_page (assistant, g_list_nth_data (priv->pages, 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
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
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)
|
|
|
|
{
|
|
|
|
GtkSettings *settings;
|
|
|
|
GdkScreen *screen;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (assistant));
|
|
|
|
settings = gtk_settings_get_for_screen (screen);
|
|
|
|
|
|
|
|
g_object_get (settings,
|
2011-01-24 02:50:39 +00:00
|
|
|
"gtk-alternative-button-order", &result,
|
|
|
|
NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_init (GtkAssistant *assistant)
|
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
2011-01-04 00:57:50 +00:00
|
|
|
GtkStyleContext *context;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-05-24 13:46:51 +00:00
|
|
|
assistant->priv = G_TYPE_INSTANCE_GET_PRIVATE (assistant,
|
|
|
|
GTK_TYPE_ASSISTANT,
|
|
|
|
GtkAssistantPrivate);
|
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2006-12-31 05:15:37 +00:00
|
|
|
gtk_container_set_reallocate_redraws (GTK_CONTAINER (assistant), TRUE);
|
2009-04-18 18:42:43 +00:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (assistant), 12);
|
2006-12-31 05:15:37 +00:00
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_push_composite_child ();
|
|
|
|
|
|
|
|
/* Header */
|
|
|
|
priv->header_image = gtk_image_new ();
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (priv->header_image), 1., 0.5);
|
|
|
|
gtk_widget_set_parent (priv->header_image, GTK_WIDGET (assistant));
|
|
|
|
gtk_widget_show (priv->header_image);
|
|
|
|
|
2011-01-04 00:57:50 +00:00
|
|
|
context = gtk_widget_get_style_context (priv->header_image);
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
/* Sidebar */
|
|
|
|
priv->sidebar_image = gtk_image_new ();
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (priv->sidebar_image), 0., 0.);
|
|
|
|
gtk_widget_set_parent (priv->sidebar_image, GTK_WIDGET (assistant));
|
|
|
|
gtk_widget_show (priv->sidebar_image);
|
|
|
|
|
2011-01-04 00:57:50 +00:00
|
|
|
context = gtk_widget_get_style_context (priv->sidebar_image);
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
|
|
|
|
|
2006-01-23 19:11:40 +00:00
|
|
|
/* Action area */
|
2010-10-31 17:07:20 +00:00
|
|
|
priv->action_area = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
|
|
|
2010-05-24 13:46:51 +00:00
|
|
|
priv->close = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
|
|
|
|
priv->apply = gtk_button_new_from_stock (GTK_STOCK_APPLY);
|
|
|
|
priv->forward = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
|
|
|
|
priv->back = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
|
|
|
|
priv->cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
|
|
|
|
priv->last = gtk_button_new_from_stock (GTK_STOCK_GOTO_LAST);
|
|
|
|
gtk_widget_set_can_default (priv->close, TRUE);
|
|
|
|
gtk_widget_set_can_default (priv->apply, TRUE);
|
|
|
|
gtk_widget_set_can_default (priv->forward, TRUE);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
priv->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_size_group_add_widget (priv->size_group, priv->close);
|
|
|
|
gtk_size_group_add_widget (priv->size_group, priv->apply);
|
|
|
|
gtk_size_group_add_widget (priv->size_group, priv->forward);
|
|
|
|
gtk_size_group_add_widget (priv->size_group, priv->back);
|
|
|
|
gtk_size_group_add_widget (priv->size_group, priv->cancel);
|
|
|
|
gtk_size_group_add_widget (priv->size_group, priv->last);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (!alternative_button_order (assistant))
|
|
|
|
{
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->close, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->cancel, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->apply, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->forward, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->back, FALSE, FALSE, 0);
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), priv->last, FALSE, FALSE, 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_parent (priv->action_area, GTK_WIDGET (assistant));
|
2010-05-24 13:46:51 +00:00
|
|
|
gtk_widget_show (priv->forward);
|
|
|
|
gtk_widget_show (priv->back);
|
|
|
|
gtk_widget_show (priv->cancel);
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_show (priv->action_area);
|
|
|
|
|
|
|
|
gtk_widget_pop_composite_child ();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-05-24 13:46:51 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->close), "clicked",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_assistant_close), assistant);
|
2010-05-24 13:46:51 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->apply), "clicked",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_assistant_apply), assistant);
|
2010-05-24 13:46:51 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->forward), "clicked",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_assistant_forward), assistant);
|
2010-05-24 13:46:51 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->back), "clicked",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_assistant_back), assistant);
|
2010-05-24 13:46:51 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->cancel), "clicked",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_assistant_cancel), assistant);
|
2010-05-24 13:46:51 +00:00
|
|
|
g_signal_connect (G_OBJECT (priv->last), "clicked",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_assistant_last), assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_set_child_property (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *child,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case CHILD_PROP_PAGE_TYPE:
|
|
|
|
gtk_assistant_set_page_type (GTK_ASSISTANT (container), child,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_value_get_enum (value));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_TITLE:
|
|
|
|
gtk_assistant_set_page_title (GTK_ASSISTANT (container), child,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_value_get_string (value));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_HEADER_IMAGE:
|
|
|
|
gtk_assistant_set_page_header_image (GTK_ASSISTANT (container), child,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_value_get_object (value));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_SIDEBAR_IMAGE:
|
|
|
|
gtk_assistant_set_page_side_image (GTK_ASSISTANT (container), child,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_value_get_object (value));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_COMPLETE:
|
|
|
|
gtk_assistant_set_page_complete (GTK_ASSISTANT (container), child,
|
2011-01-24 02:50:39 +00:00
|
|
|
g_value_get_boolean (value));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_get_child_property (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *child,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case CHILD_PROP_PAGE_TYPE:
|
|
|
|
g_value_set_enum (value,
|
2011-01-24 02:50:39 +00:00
|
|
|
gtk_assistant_get_page_type (GTK_ASSISTANT (container), child));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_TITLE:
|
|
|
|
g_value_set_string (value,
|
2011-01-24 02:50:39 +00:00
|
|
|
gtk_assistant_get_page_title (GTK_ASSISTANT (container), child));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_HEADER_IMAGE:
|
|
|
|
g_value_set_object (value,
|
2011-01-24 02:50:39 +00:00
|
|
|
gtk_assistant_get_page_header_image (GTK_ASSISTANT (container), child));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_SIDEBAR_IMAGE:
|
|
|
|
g_value_set_object (value,
|
2011-01-24 02:50:39 +00:00
|
|
|
gtk_assistant_get_page_side_image (GTK_ASSISTANT (container), child));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
case CHILD_PROP_PAGE_COMPLETE:
|
|
|
|
g_value_set_boolean (value,
|
2011-01-24 02:50:39 +00:00
|
|
|
gtk_assistant_get_page_complete (GTK_ASSISTANT (container), child));
|
2006-01-18 22:39:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-31 16:57:18 +00:00
|
|
|
static void
|
|
|
|
on_page_notify_visibility (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GParamSpec *arg,
|
|
|
|
gpointer data)
|
2006-01-31 16:57:18 +00:00
|
|
|
{
|
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (data);
|
|
|
|
|
|
|
|
/* update buttons state, flow may have changed */
|
2010-03-02 04:19:28 +00:00
|
|
|
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
|
2006-01-31 16:57:18 +00:00
|
|
|
set_assistant_buttons_state (assistant);
|
|
|
|
}
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
static void
|
2011-01-24 02:50:39 +00:00
|
|
|
remove_page (GtkAssistant *assistant,
|
|
|
|
GList *element)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
GtkAssistantPage *page_info;
|
2007-01-03 20:40:30 +00:00
|
|
|
GList *page_node;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
page_info = element->data;
|
|
|
|
|
2007-01-03 20:40:30 +00:00
|
|
|
/* If this is the current page, we need to switch away. */
|
|
|
|
if (page_info == priv->current_page)
|
|
|
|
{
|
|
|
|
if (!compute_next_step (assistant))
|
|
|
|
{
|
2011-01-24 02:50:39 +00:00
|
|
|
/* The best we can do at this point is probably to pick
|
|
|
|
* the first visible page.
|
|
|
|
*/
|
|
|
|
page_node = priv->pages;
|
2007-01-03 20:40:30 +00:00
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
while (page_node &&
|
|
|
|
!gtk_widget_get_visible (((GtkAssistantPage *) page_node->data)->page))
|
|
|
|
page_node = page_node->next;
|
2007-01-03 20:40:30 +00:00
|
|
|
|
2008-01-08 03:50:29 +00:00
|
|
|
if (page_node == element)
|
|
|
|
page_node = page_node->next;
|
|
|
|
|
2011-01-24 02:50:39 +00:00
|
|
|
if (page_node)
|
|
|
|
priv->current_page = page_node->data;
|
|
|
|
else
|
|
|
|
priv->current_page = NULL;
|
2007-01-03 20:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
priv->pages = g_list_remove_link (priv->pages, element);
|
|
|
|
priv->visited_pages = g_slist_remove_all (priv->visited_pages, page_info);
|
2006-01-31 16:57:18 +00:00
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (page_info->page, on_page_notify_visibility, assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_unparent (page_info->page);
|
|
|
|
|
|
|
|
if (page_info->header_image)
|
|
|
|
g_object_unref (page_info->header_image);
|
|
|
|
|
|
|
|
if (page_info->sidebar_image)
|
|
|
|
g_object_unref (page_info->sidebar_image);
|
|
|
|
|
|
|
|
gtk_widget_destroy (page_info->title);
|
2008-07-04 14:27:40 +00:00
|
|
|
g_slice_free (GtkAssistantPage, page_info);
|
2006-01-18 22:39:14 +00:00
|
|
|
g_list_free_1 (element);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (priv->header_image)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (priv->header_image);
|
|
|
|
priv->header_image = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->sidebar_image)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (priv->sidebar_image);
|
|
|
|
priv->sidebar_image = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->action_area)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (priv->action_area);
|
|
|
|
priv->action_area = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->size_group)
|
|
|
|
{
|
|
|
|
g_object_unref (priv->size_group);
|
|
|
|
priv->size_group = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We set current to NULL so that the remove code doesn't try
|
|
|
|
* to do anything funny */
|
|
|
|
priv->current_page = NULL;
|
|
|
|
|
|
|
|
while (priv->pages)
|
2010-09-18 23:55:42 +00:00
|
|
|
remove_page (assistant, priv->pages);
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
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;
|
|
|
|
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
|
|
|
|
set_title_font (GtkWidget *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *title_label)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
|
|
|
PangoFontDescription *desc;
|
2011-01-04 00:57:50 +00:00
|
|
|
GtkStyleContext *context;
|
2006-01-18 22:39:14 +00:00
|
|
|
gint size;
|
|
|
|
|
2011-01-28 04:23:43 +00:00
|
|
|
gtk_widget_override_font (title_label, NULL);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
desc = pango_font_description_new ();
|
2011-01-04 00:57:50 +00:00
|
|
|
context = gtk_widget_get_style_context (title_label);
|
|
|
|
size = pango_font_description_get_size (gtk_style_context_get_font (context, 0));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
pango_font_description_set_weight (desc, PANGO_WEIGHT_ULTRABOLD);
|
|
|
|
pango_font_description_set_size (desc, size * PANGO_SCALE_XX_LARGE);
|
|
|
|
|
2011-01-28 04:23:43 +00:00
|
|
|
gtk_widget_override_font (title_label, desc);
|
2006-01-18 22:39:14 +00:00
|
|
|
pango_font_description_free (desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-04 00:57:50 +00:00
|
|
|
gtk_assistant_style_updated (GtkWidget *widget)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
GList *list;
|
|
|
|
|
2011-02-07 12:30:37 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_assistant_parent_class)->style_updated (widget);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
list = priv->pages;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
GtkAssistantPage *page = list->data;
|
|
|
|
|
|
|
|
set_title_font (widget, page->title);
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_size_request (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkRequisition *requisition)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
GtkRequisition child_requisition;
|
|
|
|
gint header_padding, content_padding;
|
|
|
|
gint width, height, header_width, header_height;
|
2010-06-02 04:28:22 +00:00
|
|
|
guint border_width;
|
2006-01-18 22:39:14 +00:00
|
|
|
GList *list;
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
"header-padding", &header_padding,
|
|
|
|
"content-padding", &content_padding,
|
|
|
|
NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
width = height = 0;
|
|
|
|
header_width = header_height = 0;
|
|
|
|
list = priv->pages;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
GtkAssistantPage *page = list->data;
|
|
|
|
gint w, h;
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (page->page,
|
|
|
|
&child_requisition, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
width = MAX (width, child_requisition.width);
|
|
|
|
height = MAX (height, child_requisition.height);
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (page->title,
|
|
|
|
&child_requisition, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
w = child_requisition.width;
|
|
|
|
h = child_requisition.height;
|
|
|
|
|
|
|
|
if (page->header_image)
|
2011-01-24 02:50:39 +00:00
|
|
|
{
|
|
|
|
w += gdk_pixbuf_get_width (page->header_image) + HEADER_SPACING;
|
|
|
|
h = MAX (h, gdk_pixbuf_get_height (page->header_image));
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
header_width = MAX (header_width, w);
|
|
|
|
header_height = MAX (header_height, h);
|
|
|
|
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->sidebar_image,
|
|
|
|
&child_requisition, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
width += child_requisition.width;
|
|
|
|
height = MAX (height, child_requisition.height);
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (priv->header_image, header_width, header_height);
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->header_image,
|
|
|
|
&child_requisition, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
width = MAX (width, header_width) + 2 * header_padding;
|
|
|
|
height += header_height + 2 * header_padding;
|
|
|
|
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->action_area,
|
|
|
|
&child_requisition, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
width = MAX (width, child_requisition.width);
|
2006-01-30 15:51:54 +00:00
|
|
|
height += child_requisition.height + ACTION_AREA_SPACING;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-06-02 04:28:22 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
|
|
|
width += border_width * 2 + content_padding * 2;
|
|
|
|
height += border_width * 2 + content_padding * 2;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
requisition->width = width;
|
|
|
|
requisition->height = height;
|
|
|
|
}
|
|
|
|
|
2010-10-27 00:57:23 +00:00
|
|
|
static void
|
|
|
|
gtk_assistant_get_preferred_width (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural)
|
|
|
|
{
|
|
|
|
GtkRequisition requisition;
|
|
|
|
|
|
|
|
gtk_assistant_size_request (widget, &requisition);
|
|
|
|
|
|
|
|
*minimum = *natural = requisition.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_get_preferred_height (GtkWidget *widget,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural)
|
|
|
|
{
|
|
|
|
GtkRequisition requisition;
|
|
|
|
|
|
|
|
gtk_assistant_size_request (widget, &requisition);
|
|
|
|
|
|
|
|
*minimum = *natural = requisition.height;
|
|
|
|
}
|
2010-04-19 00:11:43 +00:00
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
static void
|
|
|
|
gtk_assistant_size_allocate (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkAllocation *allocation)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2010-04-19 00:11:43 +00:00
|
|
|
GtkRequisition header_requisition, action_requisition, sidebar_requisition;
|
2006-01-18 22:39:14 +00:00
|
|
|
GtkAllocation child_allocation, header_allocation;
|
2010-08-11 21:18:32 +00:00
|
|
|
GtkAllocation action_area_allocation, header_image_allocation;
|
2006-01-18 22:39:14 +00:00
|
|
|
gint header_padding, content_padding;
|
2010-06-02 04:28:22 +00:00
|
|
|
guint border_width;
|
2006-01-18 22:39:14 +00:00
|
|
|
gboolean rtl;
|
|
|
|
GList *pages;
|
|
|
|
|
|
|
|
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
|
|
|
pages = priv->pages;
|
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
"header-padding", &header_padding,
|
|
|
|
"content-padding", &content_padding,
|
|
|
|
NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-08-11 21:18:32 +00:00
|
|
|
gtk_widget_set_allocation (widget, allocation);
|
2010-06-02 04:28:22 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
/* Header */
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->header_image,
|
|
|
|
&header_requisition, NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-06-02 04:28:22 +00:00
|
|
|
header_allocation.x = border_width + header_padding;
|
|
|
|
header_allocation.y = border_width + header_padding;
|
|
|
|
header_allocation.width = allocation->width - 2 * border_width - 2 * header_padding;
|
2006-01-18 22:39:14 +00:00
|
|
|
header_allocation.height = header_requisition.height;
|
|
|
|
|
|
|
|
gtk_widget_size_allocate (priv->header_image, &header_allocation);
|
|
|
|
|
|
|
|
/* Action area */
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->action_area,
|
|
|
|
&action_requisition, NULL);
|
2010-04-19 00:11:43 +00:00
|
|
|
|
2010-06-02 04:28:22 +00:00
|
|
|
child_allocation.x = border_width;
|
|
|
|
child_allocation.y = allocation->height - border_width - action_requisition.height;
|
|
|
|
child_allocation.width = allocation->width - 2 * border_width;
|
2010-04-19 00:11:43 +00:00
|
|
|
child_allocation.height = action_requisition.height;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_size_allocate (priv->action_area, &child_allocation);
|
|
|
|
|
2010-08-11 21:18:32 +00:00
|
|
|
gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
|
|
|
|
gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
/* Sidebar */
|
2010-09-21 14:35:17 +00:00
|
|
|
gtk_widget_get_preferred_size (priv->sidebar_image,
|
|
|
|
&sidebar_requisition, NULL);
|
2010-04-19 00:11:43 +00:00
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
if (rtl)
|
2010-06-02 04:28:22 +00:00
|
|
|
child_allocation.x = allocation->width - border_width - sidebar_requisition.width;
|
2006-01-18 22:39:14 +00:00
|
|
|
else
|
2010-06-02 04:28:22 +00:00
|
|
|
child_allocation.x = border_width;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-08-11 21:18:32 +00:00
|
|
|
child_allocation.y = border_width + header_image_allocation.height + 2 * header_padding;
|
2010-04-19 00:11:43 +00:00
|
|
|
child_allocation.width = sidebar_requisition.width;
|
2010-06-02 04:28:22 +00:00
|
|
|
child_allocation.height = allocation->height - 2 * border_width -
|
2010-08-11 21:18:32 +00:00
|
|
|
header_image_allocation.height - 2 * header_padding - action_area_allocation.height;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_size_allocate (priv->sidebar_image, &child_allocation);
|
|
|
|
|
|
|
|
/* Pages */
|
2010-06-02 04:28:22 +00:00
|
|
|
child_allocation.x = border_width + content_padding;
|
|
|
|
child_allocation.y = border_width +
|
2010-08-11 21:18:32 +00:00
|
|
|
header_image_allocation.height + 2 * header_padding + content_padding;
|
2010-06-02 04:28:22 +00:00
|
|
|
child_allocation.width = allocation->width - 2 * border_width - 2 * content_padding;
|
|
|
|
child_allocation.height = allocation->height - 2 * border_width -
|
2010-08-11 21:18:32 +00:00
|
|
|
header_image_allocation.height - 2 * header_padding - ACTION_AREA_SPACING - action_area_allocation.height - 2 * content_padding;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (priv->sidebar_image))
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2010-08-11 21:18:32 +00:00
|
|
|
GtkAllocation sidebar_image_allocation;
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
if (!rtl)
|
2011-01-24 02:50:39 +00:00
|
|
|
child_allocation.x += sidebar_image_allocation.width;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-08-11 21:18:32 +00:00
|
|
|
child_allocation.width -= sidebar_image_allocation.width;
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while (pages)
|
|
|
|
{
|
|
|
|
GtkAssistantPage *page = pages->data;
|
|
|
|
|
|
|
|
gtk_widget_size_allocate (page->page, &child_allocation);
|
|
|
|
gtk_widget_size_allocate (page->title, &header_allocation);
|
|
|
|
pages = pages->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_map (GtkWidget *widget)
|
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
GList *page_node;
|
2009-07-17 02:06:40 +00:00
|
|
|
GtkAssistantPage *page;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-03-06 11:02:21 +00:00
|
|
|
gtk_widget_set_mapped (widget, TRUE);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_map (priv->header_image);
|
|
|
|
gtk_widget_map (priv->action_area);
|
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (priv->sidebar_image) &&
|
2010-03-02 04:19:28 +00:00
|
|
|
!gtk_widget_get_mapped (priv->sidebar_image))
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_map (priv->sidebar_image);
|
|
|
|
|
|
|
|
/* if there's no default page, pick the first one */
|
2009-07-17 02:06:40 +00:00
|
|
|
page = NULL;
|
|
|
|
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-01-24 02:50:39 +00:00
|
|
|
page_node = page_node->next;
|
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
|
|
|
}
|
|
|
|
|
2009-07-17 02:06:40 +00:00
|
|
|
if (page &&
|
2010-03-01 06:47:38 +00:00
|
|
|
gtk_widget_get_visible (page->page) &&
|
2010-03-02 04:19:28 +00:00
|
|
|
!gtk_widget_get_mapped (page->page))
|
2009-07-17 02:06:40 +00:00
|
|
|
set_current_page (assistant, page);
|
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);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-03-06 11:02:21 +00:00
|
|
|
gtk_widget_set_mapped (widget, FALSE);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_unmap (priv->header_image);
|
|
|
|
gtk_widget_unmap (priv->action_area);
|
|
|
|
|
2010-01-07 15:47:35 +00:00
|
|
|
if (gtk_widget_is_drawable (priv->sidebar_image))
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_unmap (priv->sidebar_image);
|
|
|
|
|
|
|
|
if (priv->current_page &&
|
2010-01-07 15:47:35 +00:00
|
|
|
gtk_widget_is_drawable (priv->current_page->page))
|
2011-01-21 03:39:20 +00:00
|
|
|
{
|
|
|
|
gtk_widget_set_child_visible (priv->current_page->page, FALSE);
|
|
|
|
gtk_widget_set_child_visible (priv->current_page->title, FALSE);
|
|
|
|
gtk_widget_unmap (priv->current_page->title);
|
|
|
|
gtk_widget_unmap (priv->current_page->page);
|
|
|
|
}
|
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
|
|
|
|
gtk_assistant_delete_event (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GdkEventAny *event)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
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))
|
|
|
|
g_signal_emit (widget, signals [CANCEL], 0, NULL);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-09-08 14:37:43 +00:00
|
|
|
assistant_paint_colored_box (GtkWidget *widget,
|
|
|
|
cairo_t *cr)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2010-08-11 21:18:32 +00:00
|
|
|
GtkAllocation allocation, action_area_allocation, header_image_allocation;
|
2011-01-04 00:57:50 +00:00
|
|
|
GtkStyleContext *context;
|
|
|
|
GtkStateFlags state;
|
|
|
|
GdkRGBA color;
|
2006-01-30 04:53:53 +00:00
|
|
|
gint border_width, header_padding, content_padding;
|
2006-01-18 22:39:14 +00:00
|
|
|
gint content_x, content_width;
|
|
|
|
gboolean rtl;
|
|
|
|
|
|
|
|
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
|
2006-01-30 04:53:53 +00:00
|
|
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_style_get (widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
"header-padding", &header_padding,
|
|
|
|
"content-padding", &content_padding,
|
|
|
|
NULL);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2011-01-04 00:57:50 +00:00
|
|
|
context = gtk_widget_get_style_context (widget);
|
|
|
|
state = gtk_widget_get_state_flags (widget);
|
|
|
|
|
2010-08-11 21:18:32 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
|
|
|
|
gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
/* colored box */
|
2011-01-04 00:57:50 +00:00
|
|
|
gtk_style_context_save (context);
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
|
|
|
|
|
|
|
|
gtk_style_context_get_background_color (context, state, &color);
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
cairo_rectangle (cr,
|
2011-01-24 02:50:39 +00:00
|
|
|
border_width,
|
|
|
|
border_width,
|
2010-08-11 21:18:32 +00:00
|
|
|
allocation.width - 2 * border_width,
|
|
|
|
allocation.height - action_area_allocation.height - 2 * border_width - ACTION_AREA_SPACING);
|
2006-01-18 22:39:14 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
|
|
|
|
/* content box */
|
2006-01-30 04:53:53 +00:00
|
|
|
content_x = content_padding + border_width;
|
2010-08-11 21:18:32 +00:00
|
|
|
content_width = allocation.width - 2 * content_padding - 2 * border_width;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-03-01 06:47:38 +00:00
|
|
|
if (gtk_widget_get_visible (priv->sidebar_image))
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2010-08-11 21:18:32 +00:00
|
|
|
GtkAllocation sidebar_image_allocation;
|
|
|
|
|
|
|
|
gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
if (!rtl)
|
2011-01-24 02:50:39 +00:00
|
|
|
content_x += sidebar_image_allocation.width;
|
2010-08-11 21:18:32 +00:00
|
|
|
content_width -= sidebar_image_allocation.width;
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
2010-08-11 21:18:32 +00:00
|
|
|
|
2011-01-04 00:57:50 +00:00
|
|
|
gtk_style_context_restore (context);
|
|
|
|
|
|
|
|
gtk_style_context_get_background_color (context, state, &color);
|
|
|
|
gdk_cairo_set_source_rgba (cr, &color);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
cairo_rectangle (cr,
|
2011-01-24 02:50:39 +00:00
|
|
|
content_x,
|
|
|
|
header_image_allocation.height + content_padding + 2 * header_padding + border_width,
|
|
|
|
content_width,
|
|
|
|
allocation.height - 2 * border_width - action_area_allocation.height -
|
|
|
|
header_image_allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
|
2006-01-18 22:39:14 +00:00
|
|
|
cairo_fill (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2010-09-08 14:37:43 +00:00
|
|
|
gtk_assistant_draw (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
cairo_t *cr)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = GTK_ASSISTANT (widget);
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2010-09-08 14:37:43 +00:00
|
|
|
GtkContainer *container = GTK_CONTAINER (widget);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-10-08 05:08:24 +00:00
|
|
|
if (GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw)
|
|
|
|
GTK_WIDGET_CLASS (gtk_assistant_parent_class)->draw (widget, cr);
|
|
|
|
|
2010-09-08 14:37:43 +00:00
|
|
|
assistant_paint_colored_box (widget, cr);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-09-08 14:37:43 +00:00
|
|
|
gtk_container_propagate_draw (container, priv->header_image, cr);
|
|
|
|
gtk_container_propagate_draw (container, priv->sidebar_image, cr);
|
|
|
|
gtk_container_propagate_draw (container, priv->action_area, cr);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-09-08 14:37:43 +00:00
|
|
|
if (priv->current_page)
|
|
|
|
{
|
|
|
|
gtk_container_propagate_draw (container, priv->current_page->page, cr);
|
|
|
|
gtk_container_propagate_draw (container, priv->current_page->title, cr);
|
2006-01-18 22:39:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-01-28 06:03:50 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_assistant_focus (GtkWidget *widget,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkDirectionType direction)
|
2006-01-28 06:03:50 +00:00
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkContainer *container;
|
|
|
|
|
|
|
|
container = GTK_CONTAINER (widget);
|
|
|
|
priv = GTK_ASSISTANT (widget)->priv;
|
|
|
|
|
|
|
|
/* we only have to care about 2 widgets, action area and the current page */
|
2010-06-02 04:28:22 +00:00
|
|
|
if (gtk_container_get_focus_child (container) == priv->action_area)
|
2006-01-28 06:03:50 +00:00
|
|
|
{
|
|
|
|
if (!gtk_widget_child_focus (priv->action_area, direction) &&
|
2011-01-24 02:50:39 +00:00
|
|
|
(priv->current_page == NULL ||
|
|
|
|
!gtk_widget_child_focus (priv->current_page->page, direction)))
|
|
|
|
{
|
|
|
|
/* if we're leaving the action area and the current page has no
|
|
|
|
* focusable widget, clear focus and go back to the action area
|
|
|
|
*/
|
|
|
|
gtk_container_set_focus_child (GTK_CONTAINER (priv->action_area), NULL);
|
|
|
|
gtk_widget_child_focus (priv->action_area, direction);
|
|
|
|
}
|
2006-01-28 06:03:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-10 16:19:24 +00:00
|
|
|
if ((priv->current_page == NULL ||
|
2011-01-24 02:50:39 +00:00
|
|
|
!gtk_widget_child_focus (priv->current_page->page, direction)) &&
|
|
|
|
!gtk_widget_child_focus (priv->action_area, direction))
|
|
|
|
{
|
|
|
|
/* if we're leaving the current page and there isn't nothing
|
|
|
|
* focusable in the action area, try to clear focus and go back
|
|
|
|
* to the page
|
|
|
|
*/
|
|
|
|
gtk_window_set_focus (GTK_WINDOW (widget), NULL);
|
|
|
|
if (priv->current_page != NULL)
|
|
|
|
gtk_widget_child_focus (priv->current_page->page, direction);
|
|
|
|
}
|
2006-01-28 06:03:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
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
|
|
|
{
|
2008-02-07 15:50:39 +00:00
|
|
|
GtkAssistant *assistant = (GtkAssistant*) container;
|
2006-01-18 22:39:14 +00:00
|
|
|
GList *element;
|
|
|
|
|
|
|
|
element = find_page (assistant, page);
|
|
|
|
|
|
|
|
if (element)
|
|
|
|
{
|
|
|
|
remove_page (assistant, element);
|
|
|
|
gtk_widget_queue_resize ((GtkWidget *) container);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_forall (GtkContainer *container,
|
2011-01-24 02:50:39 +00:00
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
2006-01-19 16:51:21 +00:00
|
|
|
GtkAssistant *assistant = (GtkAssistant*) container;
|
|
|
|
GtkAssistantPrivate *priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
GList *pages;
|
|
|
|
|
|
|
|
if (include_internals)
|
|
|
|
{
|
|
|
|
(*callback) (priv->header_image, callback_data);
|
|
|
|
(*callback) (priv->sidebar_image, callback_data);
|
|
|
|
(*callback) (priv->action_area, callback_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
pages = priv->pages;
|
|
|
|
|
|
|
|
while (pages)
|
|
|
|
{
|
|
|
|
GtkAssistantPage *page = (GtkAssistantPage *) pages->data;
|
|
|
|
|
|
|
|
(*callback) (page->page, callback_data);
|
|
|
|
|
|
|
|
if (include_internals)
|
2011-01-24 02:50:39 +00:00
|
|
|
(*callback) (page->title, callback_data);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
pages = pages->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_assistant_new:
|
2011-01-24 02:50:39 +00:00
|
|
|
*
|
2006-01-18 22:39:14 +00:00
|
|
|
* Creates a new #GtkAssistant.
|
|
|
|
*
|
|
|
|
* Return value: a newly created #GtkAssistant
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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
|
|
|
|
*
|
|
|
|
* Returns the page number of the current page
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Return value: The index (starting from 0) of the current
|
|
|
|
* page in the @assistant, if the @assistant has no pages,
|
|
|
|
* -1 will be returned
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
gint
|
|
|
|
gtk_assistant_get_current_page (GtkAssistant *assistant)
|
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), -1);
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
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().
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkAssistantPage *page;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (page_num >= 0)
|
|
|
|
page = (GtkAssistantPage *) g_list_nth_data (priv->pages, page_num);
|
|
|
|
else
|
2010-02-23 16:16:04 +00:00
|
|
|
page = (GtkAssistantPage *) g_list_last (priv->pages)->data;
|
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
|
|
|
|
2006-01-31 16:57:18 +00:00
|
|
|
set_current_page (assistant, page);
|
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
|
|
|
*
|
|
|
|
* Since: 3.0
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
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
|
|
|
*
|
|
|
|
* Since: 3.0
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2010-10-30 19:12:58 +00:00
|
|
|
void
|
|
|
|
gtk_assistant_previous_page (GtkAssistant *assistant)
|
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
GSList *page_node;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
priv = assistant->priv;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
set_current_page (assistant, page_info);
|
|
|
|
}
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
/**
|
|
|
|
* gtk_assistant_get_n_pages:
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
*
|
|
|
|
* Returns the number of pages in the @assistant
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Return value: the number of pages in the @assistant
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
gint
|
|
|
|
gtk_assistant_get_n_pages (GtkAssistant *assistant)
|
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Return value: (transfer none): the child widget, or %NULL
|
|
|
|
* if @page_num is out of bounds
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
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
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
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
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
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.
|
|
|
|
*
|
|
|
|
* Return value: the index (starting at 0) of the inserted page
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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.
|
|
|
|
*
|
|
|
|
* Return value: the index (starting at 0) of the inserted page
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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.
|
|
|
|
*
|
|
|
|
* Return value: the index (starting from 0) of the inserted page
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkAssistantPage *page_info;
|
2011-01-04 00:57:50 +00:00
|
|
|
GtkStyleContext *context;
|
2006-01-18 22:39:14 +00:00
|
|
|
gint n_pages;
|
|
|
|
|
|
|
|
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);
|
2010-01-04 06:49:26 +00:00
|
|
|
g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2008-07-04 14:27:40 +00:00
|
|
|
page_info = g_slice_new0 (GtkAssistantPage);
|
2006-01-18 22:39:14 +00:00
|
|
|
page_info->page = page;
|
|
|
|
page_info->title = gtk_label_new (NULL);
|
|
|
|
|
2006-01-31 16:57:18 +00:00
|
|
|
g_signal_connect (G_OBJECT (page), "notify::visible",
|
2011-01-24 02:50:39 +00:00
|
|
|
G_CALLBACK (on_page_notify_visibility), assistant);
|
2006-01-31 16:57:18 +00:00
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (page_info->title), 0.,0.5);
|
|
|
|
set_title_font (GTK_WIDGET (assistant), page_info->title);
|
|
|
|
gtk_widget_show (page_info->title);
|
|
|
|
|
2011-01-04 00:57:50 +00:00
|
|
|
context = gtk_widget_get_style_context (page_info->title);
|
|
|
|
gtk_style_context_add_class (context, GTK_STYLE_CLASS_HIGHLIGHT);
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
n_pages = g_list_length (priv->pages);
|
|
|
|
|
|
|
|
if (position < 0 || position > n_pages)
|
|
|
|
position = n_pages;
|
|
|
|
|
|
|
|
priv->pages = g_list_insert (priv->pages, page_info, position);
|
|
|
|
|
2006-01-30 04:53:53 +00:00
|
|
|
gtk_widget_set_child_visible (page_info->page, FALSE);
|
2011-01-21 03:39:20 +00:00
|
|
|
gtk_widget_set_child_visible (page_info->title, FALSE);
|
2006-01-18 22:39:14 +00:00
|
|
|
gtk_widget_set_parent (page_info->page, GTK_WIDGET (assistant));
|
|
|
|
gtk_widget_set_parent (page_info->title, GTK_WIDGET (assistant));
|
|
|
|
|
2010-03-02 06:16:02 +00:00
|
|
|
if (gtk_widget_get_realized (GTK_WIDGET (assistant)))
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
|
|
|
gtk_widget_realize (page_info->page);
|
|
|
|
gtk_widget_realize (page_info->title);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (assistant));
|
|
|
|
|
|
|
|
return position;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
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
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2007-06-06 14:24:31 +00:00
|
|
|
set_assistant_buttons_state (assistant);
|
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.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (GTK_IS_BUTTON (child))
|
|
|
|
gtk_size_group_add_widget (priv->size_group, child);
|
|
|
|
|
|
|
|
gtk_box_pack_end (GTK_BOX (priv->action_area), child, FALSE, FALSE, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (child));
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (GTK_IS_BUTTON (child))
|
|
|
|
gtk_size_group_remove_widget (priv->size_group, child);
|
|
|
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
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;
|
|
|
|
|
|
|
|
gtk_label_set_text ((GtkLabel*) page_info->title, title);
|
|
|
|
gtk_widget_queue_resize (GTK_WIDGET (assistant));
|
|
|
|
gtk_widget_child_notify (page, "title");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Return value: the title for @page
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
G_CONST_RETURN gchar*
|
|
|
|
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;
|
|
|
|
|
|
|
|
return gtk_label_get_text ((GtkLabel*) page_info->title);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
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;
|
|
|
|
|
|
|
|
if (type != page_info->type)
|
|
|
|
{
|
|
|
|
page_info->type = type;
|
|
|
|
|
2009-12-10 16:34:29 +00:00
|
|
|
/* backwards compatibility to the era before fixing bug 604289 */
|
|
|
|
if (type == GTK_ASSISTANT_PAGE_SUMMARY && !page_info->complete_set)
|
|
|
|
{
|
|
|
|
gtk_assistant_set_page_complete (assistant, page, TRUE);
|
|
|
|
page_info->complete_set = FALSE;
|
|
|
|
}
|
|
|
|
|
2006-01-18 22:39:14 +00:00
|
|
|
/* Always set buttons state, a change in a future page
|
2011-01-24 02:50:39 +00:00
|
|
|
* might change current page buttons
|
|
|
|
*/
|
2007-06-06 14:24:31 +00:00
|
|
|
set_assistant_buttons_state (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_child_notify (page, "page-type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_assistant_get_page_type:
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
* @page: a page of @assistant
|
|
|
|
*
|
|
|
|
* Gets the page type of @page.
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Return value: the page type of @page
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
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_header_image:
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-07-17 03:43:29 +00:00
|
|
|
* @page: a page of @assistant
|
2009-12-10 10:23:40 +00:00
|
|
|
* @pixbuf: (allow-none): the new header image @page
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Sets a header image for @page.
|
|
|
|
*
|
|
|
|
* This image is displayed in the header area of the assistant
|
|
|
|
* when @page is the current page.
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
void
|
|
|
|
gtk_assistant_set_page_header_image (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *page,
|
|
|
|
GdkPixbuf *pixbuf)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (page));
|
|
|
|
g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
|
|
if (pixbuf != page_info->header_image)
|
|
|
|
{
|
|
|
|
if (page_info->header_image)
|
2011-01-24 02:50:39 +00:00
|
|
|
{
|
|
|
|
g_object_unref (page_info->header_image);
|
|
|
|
page_info->header_image = NULL;
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (pixbuf)
|
2011-01-24 02:50:39 +00:00
|
|
|
page_info->header_image = g_object_ref (pixbuf);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (page_info == priv->current_page)
|
2011-01-24 02:50:39 +00:00
|
|
|
set_assistant_header_image (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_child_notify (page, "header-image");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_assistant_get_page_header_image:
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
* @page: a page of @assistant
|
2010-09-21 04:18:11 +00:00
|
|
|
*
|
|
|
|
* Gets the header image for @page.
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Return value: (transfer none): the header image for @page,
|
|
|
|
* or %NULL if there's no header image for the page
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
GdkPixbuf*
|
|
|
|
gtk_assistant_get_page_header_image (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;
|
|
|
|
|
|
|
|
return page_info->header_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_assistant_set_page_side_image:
|
|
|
|
* @assistant: a #GtkAssistant
|
2006-07-17 03:43:29 +00:00
|
|
|
* @page: a page of @assistant
|
2009-12-10 10:23:40 +00:00
|
|
|
* @pixbuf: (allow-none): the new header image @page
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Sets a header image for @page.
|
|
|
|
*
|
|
|
|
* This image is displayed in the side area of the assistant
|
|
|
|
* when @page is the current page.
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
void
|
|
|
|
gtk_assistant_set_page_side_image (GtkAssistant *assistant,
|
2011-01-24 02:50:39 +00:00
|
|
|
GtkWidget *page,
|
|
|
|
GdkPixbuf *pixbuf)
|
2006-01-18 22:39:14 +00:00
|
|
|
{
|
|
|
|
GtkAssistantPrivate *priv;
|
|
|
|
GtkAssistantPage *page_info;
|
|
|
|
GList *child;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
g_return_if_fail (GTK_IS_WIDGET (page));
|
|
|
|
g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
|
|
|
|
|
2006-01-19 16:51:21 +00:00
|
|
|
priv = assistant->priv;
|
2006-01-18 22:39:14 +00:00
|
|
|
child = find_page (assistant, page);
|
|
|
|
|
|
|
|
g_return_if_fail (child != NULL);
|
|
|
|
|
|
|
|
page_info = (GtkAssistantPage*) child->data;
|
|
|
|
|
|
|
|
if (pixbuf != page_info->sidebar_image)
|
|
|
|
{
|
|
|
|
if (page_info->sidebar_image)
|
2011-01-24 02:50:39 +00:00
|
|
|
{
|
|
|
|
g_object_unref (page_info->sidebar_image);
|
|
|
|
page_info->sidebar_image = NULL;
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (pixbuf)
|
2011-01-24 02:50:39 +00:00
|
|
|
page_info->sidebar_image = g_object_ref (pixbuf);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
if (page_info == priv->current_page)
|
2011-01-24 02:50:39 +00:00
|
|
|
set_assistant_sidebar_image (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_child_notify (page, "sidebar-image");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_assistant_get_page_side_image:
|
|
|
|
* @assistant: a #GtkAssistant
|
|
|
|
* @page: a page of @assistant
|
2010-09-21 04:18:11 +00:00
|
|
|
*
|
|
|
|
* Gets the header image for @page.
|
|
|
|
*
|
2011-01-24 02:50:39 +00:00
|
|
|
* Return value: (transfer none): the side image for @page,
|
|
|
|
* or %NULL if there's no side image for the page
|
2006-01-18 22:39:14 +00:00
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2006-01-18 22:39:14 +00:00
|
|
|
GdkPixbuf*
|
|
|
|
gtk_assistant_get_page_side_image (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;
|
|
|
|
|
|
|
|
return page_info->sidebar_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* Since: 2.10
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
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;
|
|
|
|
|
|
|
|
if (complete != page_info->complete)
|
|
|
|
{
|
|
|
|
page_info->complete = complete;
|
2009-12-10 16:34:29 +00:00
|
|
|
page_info->complete_set = TRUE;
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
/* Always set buttons state, a change in a future page
|
2011-01-24 02:50:39 +00:00
|
|
|
* might change current page buttons
|
|
|
|
*/
|
2007-06-06 14:24:31 +00:00
|
|
|
set_assistant_buttons_state (assistant);
|
2006-01-18 22:39:14 +00:00
|
|
|
|
|
|
|
gtk_widget_child_notify (page, "complete");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
*
|
2006-01-18 22:39:14 +00:00
|
|
|
* Return value: %TRUE if @page is complete.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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.
|
|
|
|
*
|
|
|
|
* Since: 2.10
|
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));
|
|
|
|
|
|
|
|
set_assistant_buttons_state (assistant);
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* Since: 2.22
|
2011-01-24 02:50:39 +00:00
|
|
|
*/
|
2010-06-02 20:00:16 +00:00
|
|
|
void
|
|
|
|
gtk_assistant_commit (GtkAssistant *assistant)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_ASSISTANT (assistant));
|
|
|
|
|
|
|
|
g_slist_free (assistant->priv->visited_pages);
|
|
|
|
assistant->priv->visited_pages = NULL;
|
|
|
|
|
|
|
|
assistant->priv->committed = TRUE;
|
|
|
|
|
|
|
|
set_assistant_buttons_state (assistant);
|
|
|
|
}
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
static AtkObject *
|
|
|
|
gtk_assistant_get_accessible (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
static gboolean first_time = TRUE;
|
|
|
|
|
|
|
|
if (first_time)
|
|
|
|
{
|
2011-02-17 17:25:23 +00:00
|
|
|
_gtk_accessible_set_factory_type (GTK_TYPE_ASSISTANT,
|
|
|
|
gtk_assistant_accessible_factory_get_type ());
|
2010-11-29 15:40:29 +00:00
|
|
|
|
|
|
|
first_time = FALSE;
|
|
|
|
}
|
2006-01-18 22:39:14 +00:00
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
return GTK_WIDGET_CLASS (gtk_assistant_parent_class)->get_accessible (widget);
|
|
|
|
}
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
|
|
/* accessible implementation */
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
/* dummy typedefs */
|
|
|
|
typedef struct _GtkAssistantAccessible GtkAssistantAccessible;
|
|
|
|
typedef struct _GtkAssistantAccessibleClass GtkAssistantAccessibleClass;
|
|
|
|
|
2010-12-05 17:18:30 +00:00
|
|
|
ATK_DEFINE_TYPE (GtkAssistantAccessible, _gtk_assistant_accessible, GTK_TYPE_ASSISTANT);
|
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)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2011-02-17 17:35:07 +00:00
|
|
|
return g_list_length (GTK_ASSISTANT (widget)->priv->pages) + 1;
|
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);
|
|
|
|
priv = assistant->priv;
|
|
|
|
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
|
|
|
}
|
|
|
|
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
|
|
|
/* factory */
|
|
|
|
typedef AtkObjectFactory GtkAssistantAccessibleFactory;
|
|
|
|
typedef AtkObjectFactoryClass GtkAssistantAccessibleFactoryClass;
|
2006-06-12 03:53:19 +00:00
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
G_DEFINE_TYPE (GtkAssistantAccessibleFactory,
|
|
|
|
gtk_assistant_accessible_factory,
|
|
|
|
ATK_TYPE_OBJECT_FACTORY);
|
2006-06-12 03:53:19 +00:00
|
|
|
|
|
|
|
static GType
|
|
|
|
gtk_assistant_accessible_factory_get_accessible_type (void)
|
|
|
|
{
|
2010-12-05 17:18:30 +00:00
|
|
|
return _gtk_assistant_accessible_get_type ();
|
2006-06-12 03:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static AtkObject*
|
|
|
|
gtk_assistant_accessible_factory_create_accessible (GObject *obj)
|
|
|
|
{
|
2010-11-29 15:40:29 +00:00
|
|
|
AtkObject *accessible;
|
|
|
|
|
2010-12-05 17:18:30 +00:00
|
|
|
accessible = g_object_new (_gtk_assistant_accessible_get_type (), NULL);
|
2010-11-29 15:40:29 +00:00
|
|
|
atk_object_initialize (accessible, obj);
|
|
|
|
|
|
|
|
return accessible;
|
2006-06-12 03:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_assistant_accessible_factory_class_init (AtkObjectFactoryClass *class)
|
|
|
|
{
|
|
|
|
class->create_accessible = gtk_assistant_accessible_factory_create_accessible;
|
|
|
|
class->get_accessible_type = gtk_assistant_accessible_factory_get_accessible_type;
|
|
|
|
}
|
|
|
|
|
2010-11-29 15:40:29 +00:00
|
|
|
static void
|
|
|
|
gtk_assistant_accessible_factory_init (AtkObjectFactory *factory)
|
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->get_internal_child = gtk_assistant_buildable_get_internal_child;
|
|
|
|
iface->custom_tag_start = gtk_assistant_buildable_custom_tag_start;
|
|
|
|
iface->custom_finished = gtk_assistant_buildable_custom_finished;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gtk_assistant_buildable_get_internal_child (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
const gchar *childname)
|
|
|
|
{
|
|
|
|
if (strcmp (childname, "action_area") == 0)
|
|
|
|
return G_OBJECT (GTK_ASSISTANT (buildable)->priv->action_area);
|
|
|
|
|
|
|
|
return parent_buildable_iface->get_internal_child (buildable,
|
|
|
|
builder,
|
|
|
|
childname);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gtk_assistant_buildable_custom_tag_start (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *tagname,
|
|
|
|
GMarkupParser *parser,
|
|
|
|
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);
|
|
|
|
}
|