2014-02-08 20:27:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013 - 2014 Red Hat, Inc.
|
|
|
|
*
|
|
|
|
* This program 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 program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtkactionbar.h"
|
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkaccessible.h"
|
|
|
|
#include "gtkbuildable.h"
|
|
|
|
#include "gtktypebuiltins.h"
|
2014-02-17 04:02:05 +00:00
|
|
|
#include "gtkbox.h"
|
2014-02-08 20:27:13 +00:00
|
|
|
#include "gtkrevealer.h"
|
2015-12-06 04:10:52 +00:00
|
|
|
#include "gtkcsscustomgadgetprivate.h"
|
|
|
|
#include "gtkwidgetprivate.h"
|
|
|
|
#include "gtkcontainerprivate.h"
|
2017-01-08 13:52:34 +00:00
|
|
|
#include "gtkprivate.h"
|
2014-02-08 20:27:13 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gtkactionbar
|
|
|
|
* @Short_description: A full width bar for presenting contextual actions
|
|
|
|
* @Title: GtkActionBar
|
|
|
|
* @See_also: #GtkBox
|
|
|
|
*
|
|
|
|
* GtkActionBar is designed to present contextual actions. It is
|
|
|
|
* expected to be displayed below the content and expand horizontally
|
|
|
|
* to fill the area.
|
|
|
|
*
|
|
|
|
* It allows placing children at the start or the end. In addition, it
|
|
|
|
* contains an internal centered box which is centered with respect to
|
|
|
|
* the full width of the box, even if the children at either side take
|
|
|
|
* up different amounts of space.
|
2015-10-29 11:08:15 +00:00
|
|
|
*
|
|
|
|
* # CSS nodes
|
|
|
|
*
|
|
|
|
* GtkActionBar has a single CSS node with name actionbar.
|
2014-02-08 20:27:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct _GtkActionBarPrivate
|
|
|
|
{
|
2014-11-12 04:01:16 +00:00
|
|
|
GtkWidget *box;
|
2014-02-08 20:27:13 +00:00
|
|
|
GtkWidget *revealer;
|
2015-12-06 04:10:52 +00:00
|
|
|
GtkCssGadget *gadget;
|
2014-02-08 20:27:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CHILD_PROP_0,
|
|
|
|
CHILD_PROP_PACK_TYPE,
|
|
|
|
CHILD_PROP_POSITION
|
|
|
|
};
|
|
|
|
|
2017-01-08 13:52:34 +00:00
|
|
|
enum {
|
|
|
|
PROP_REVEALED,
|
|
|
|
LAST_PROP
|
|
|
|
};
|
|
|
|
static GParamSpec *props[LAST_PROP] = { NULL, };
|
|
|
|
|
2015-12-06 04:10:52 +00:00
|
|
|
static void gtk_action_bar_buildable_interface_init (GtkBuildableIface *iface);
|
2014-02-08 20:27:13 +00:00
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkActionBar, gtk_action_bar, GTK_TYPE_CONTAINER,
|
2014-02-08 20:27:13 +00:00
|
|
|
G_ADD_PRIVATE (GtkActionBar)
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
|
|
|
|
gtk_action_bar_buildable_interface_init))
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_add (GtkContainer *container,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (priv->box), child);
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_remove (GtkContainer *container,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
gtk_container_remove (GTK_CONTAINER (priv->box), child);
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
2014-02-19 01:45:15 +00:00
|
|
|
static void
|
|
|
|
gtk_action_bar_forall (GtkContainer *container,
|
|
|
|
gboolean include_internals,
|
|
|
|
GtkCallback callback,
|
|
|
|
gpointer callback_data)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
|
|
|
|
|
|
|
if (include_internals)
|
|
|
|
(* callback) (priv->revealer, callback_data);
|
2016-01-18 23:53:55 +00:00
|
|
|
else if (priv->box)
|
2014-11-12 04:01:16 +00:00
|
|
|
gtk_container_forall (GTK_CONTAINER (priv->box), callback, callback_data);
|
2014-02-19 01:45:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-19 06:33:12 +00:00
|
|
|
static void
|
2017-01-08 09:49:06 +00:00
|
|
|
gtk_action_bar_finalize (GObject *object)
|
2014-02-19 06:33:12 +00:00
|
|
|
{
|
2017-01-08 09:49:06 +00:00
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (object));
|
2014-02-19 06:33:12 +00:00
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
g_clear_object (&priv->gadget);
|
|
|
|
gtk_widget_unparent (priv->revealer);
|
2014-02-19 06:33:12 +00:00
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
G_OBJECT_CLASS (gtk_action_bar_parent_class)->finalize (object);
|
2014-02-19 06:33:12 +00:00
|
|
|
}
|
|
|
|
|
2014-02-08 20:27:13 +00:00
|
|
|
static GType
|
|
|
|
gtk_action_bar_child_type (GtkContainer *container)
|
|
|
|
{
|
|
|
|
return GTK_TYPE_WIDGET;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_get_child_property (GtkContainer *container,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
|
|
|
|
|
|
|
if (child == priv->revealer)
|
|
|
|
g_param_value_set_default (pspec, value);
|
|
|
|
else
|
2014-11-12 04:01:16 +00:00
|
|
|
gtk_container_child_get_property (GTK_CONTAINER (priv->box),
|
2014-02-08 20:27:13 +00:00
|
|
|
child,
|
|
|
|
pspec->name,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_set_child_property (GtkContainer *container,
|
|
|
|
GtkWidget *child,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (container));
|
|
|
|
|
|
|
|
if (child != priv->revealer)
|
2014-11-12 04:01:16 +00:00
|
|
|
gtk_container_child_set_property (GTK_CONTAINER (priv->box),
|
2014-02-08 20:27:13 +00:00
|
|
|
child,
|
|
|
|
pspec->name,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
|
2016-11-14 20:43:24 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_action_bar_render (GtkCssGadget *gadget,
|
|
|
|
GtkSnapshot *snapshot,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
gpointer data)
|
2015-12-06 04:10:52 +00:00
|
|
|
{
|
2016-11-14 20:43:24 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_action_bar_parent_class)->snapshot (gtk_css_gadget_get_owner (gadget), snapshot);
|
2016-08-04 18:18:58 +00:00
|
|
|
|
2016-11-14 20:43:24 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-12-06 04:10:52 +00:00
|
|
|
|
2016-11-14 20:43:24 +00:00
|
|
|
static void
|
|
|
|
gtk_action_bar_snapshot (GtkWidget *widget,
|
|
|
|
GtkSnapshot *snapshot)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (widget));
|
2015-12-06 04:10:52 +00:00
|
|
|
|
2016-11-14 20:43:24 +00:00
|
|
|
gtk_css_gadget_snapshot (priv->gadget, snapshot);
|
2015-12-06 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_allocate (GtkCssGadget *gadget,
|
|
|
|
const GtkAllocation *allocation,
|
|
|
|
int baseline,
|
|
|
|
GtkAllocation *out_clip,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
2015-12-19 03:57:16 +00:00
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (widget));
|
2015-12-06 04:10:52 +00:00
|
|
|
|
2015-12-19 03:57:16 +00:00
|
|
|
gtk_widget_size_allocate (priv->revealer, (GtkAllocation *)allocation);
|
2015-12-06 04:10:52 +00:00
|
|
|
|
|
|
|
gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (widget));
|
|
|
|
GtkAllocation clip;
|
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_action_bar_parent_class)->size_allocate (widget, allocation);
|
2015-12-06 04:10:52 +00:00
|
|
|
|
|
|
|
gtk_css_gadget_allocate (priv->gadget, allocation, gtk_widget_get_allocated_baseline (widget), &clip);
|
|
|
|
|
|
|
|
gtk_widget_set_clip (widget, &clip);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_measure (GtkCssGadget *gadget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (widget));
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
gtk_widget_measure (priv->revealer,
|
|
|
|
orientation,
|
|
|
|
for_size,
|
|
|
|
minimum, natural,
|
|
|
|
minimum_baseline, natural_baseline);
|
2015-12-06 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-10-22 14:06:14 +00:00
|
|
|
gtk_action_bar_measure_ (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline)
|
2015-12-06 04:10:52 +00:00
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (GTK_ACTION_BAR (widget));
|
|
|
|
|
|
|
|
gtk_css_gadget_get_preferred_size (priv->gadget,
|
2016-10-22 14:06:14 +00:00
|
|
|
orientation,
|
|
|
|
for_size,
|
2015-12-06 04:10:52 +00:00
|
|
|
minimum, natural,
|
|
|
|
minimum_baseline, natural_baseline);
|
|
|
|
}
|
|
|
|
|
2017-01-08 13:52:34 +00:00
|
|
|
static void
|
|
|
|
gtk_action_bar_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkActionBar *action_bar = GTK_ACTION_BAR (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_REVEALED:
|
|
|
|
gtk_action_bar_set_revealed (action_bar, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkActionBar *action_bar = GTK_ACTION_BAR (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_REVEALED:
|
|
|
|
g_value_set_boolean (value, gtk_action_bar_get_revealed (action_bar));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-08 20:27:13 +00:00
|
|
|
static void
|
|
|
|
gtk_action_bar_class_init (GtkActionBarClass *klass)
|
|
|
|
{
|
2015-12-06 04:10:52 +00:00
|
|
|
GObjectClass *object_class;
|
2014-02-08 20:27:13 +00:00
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
GtkContainerClass *container_class;
|
|
|
|
|
2015-12-06 04:10:52 +00:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
2014-02-08 20:27:13 +00:00
|
|
|
widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
container_class = GTK_CONTAINER_CLASS (klass);
|
|
|
|
|
2017-01-08 13:52:34 +00:00
|
|
|
object_class->set_property = gtk_action_bar_set_property;
|
|
|
|
object_class->get_property = gtk_action_bar_get_property;
|
2015-12-06 04:10:52 +00:00
|
|
|
object_class->finalize = gtk_action_bar_finalize;
|
|
|
|
|
2016-11-14 20:43:24 +00:00
|
|
|
widget_class->snapshot = gtk_action_bar_snapshot;
|
2015-12-06 04:10:52 +00:00
|
|
|
widget_class->size_allocate = gtk_action_bar_size_allocate;
|
2016-10-22 14:06:14 +00:00
|
|
|
widget_class->measure = gtk_action_bar_measure_;
|
2014-02-08 20:27:13 +00:00
|
|
|
|
|
|
|
container_class->add = gtk_action_bar_add;
|
|
|
|
container_class->remove = gtk_action_bar_remove;
|
2014-02-19 01:45:15 +00:00
|
|
|
container_class->forall = gtk_action_bar_forall;
|
2014-02-08 20:27:13 +00:00
|
|
|
container_class->child_type = gtk_action_bar_child_type;
|
|
|
|
container_class->set_child_property = gtk_action_bar_set_child_property;
|
|
|
|
container_class->get_child_property = gtk_action_bar_get_child_property;
|
|
|
|
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
|
|
|
CHILD_PROP_PACK_TYPE,
|
|
|
|
g_param_spec_enum ("pack-type",
|
|
|
|
P_("Pack type"),
|
|
|
|
P_("A GtkPackType indicating whether the child is packed with reference to the start or end of the parent"),
|
|
|
|
GTK_TYPE_PACK_TYPE, GTK_PACK_START,
|
|
|
|
G_PARAM_READWRITE));
|
|
|
|
gtk_container_class_install_child_property (container_class,
|
|
|
|
CHILD_PROP_POSITION,
|
|
|
|
g_param_spec_int ("position",
|
|
|
|
P_("Position"),
|
|
|
|
P_("The index of the child in the parent"),
|
|
|
|
-1, G_MAXINT, 0,
|
2014-11-12 04:02:11 +00:00
|
|
|
G_PARAM_READWRITE));
|
2014-02-08 20:27:13 +00:00
|
|
|
|
2017-01-08 13:52:34 +00:00
|
|
|
props[PROP_REVEALED] =
|
|
|
|
g_param_spec_boolean ("revealed",
|
|
|
|
P_("Reveal"),
|
|
|
|
P_("Controls whether the action bar shows its contents or not"),
|
|
|
|
TRUE,
|
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
|
|
|
|
|
2014-02-08 20:27:13 +00:00
|
|
|
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_PANEL);
|
2015-10-29 11:08:15 +00:00
|
|
|
gtk_widget_class_set_css_name (widget_class, "actionbar");
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_init (GtkActionBar *action_bar)
|
|
|
|
{
|
|
|
|
GtkWidget *widget = GTK_WIDGET (action_bar);
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
2015-12-06 04:10:52 +00:00
|
|
|
GtkCssNode *widget_node;
|
2014-02-08 20:27:13 +00:00
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
gtk_widget_set_has_window (widget, FALSE);
|
|
|
|
|
|
|
|
priv->revealer = gtk_revealer_new ();
|
|
|
|
gtk_widget_set_parent (priv->revealer, widget);
|
2014-02-08 20:27:13 +00:00
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
priv->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (priv->revealer), priv->box);
|
2014-02-08 20:27:13 +00:00
|
|
|
|
2017-01-08 09:49:06 +00:00
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), TRUE);
|
2014-02-08 20:27:13 +00:00
|
|
|
gtk_revealer_set_transition_type (GTK_REVEALER (priv->revealer), GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP);
|
2015-12-06 04:10:52 +00:00
|
|
|
|
|
|
|
widget_node = gtk_widget_get_css_node (GTK_WIDGET (action_bar));
|
|
|
|
priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
|
|
|
|
GTK_WIDGET (action_bar),
|
|
|
|
gtk_action_bar_measure,
|
|
|
|
gtk_action_bar_allocate,
|
2016-11-14 20:43:24 +00:00
|
|
|
gtk_action_bar_render,
|
2016-11-13 20:08:34 +00:00
|
|
|
NULL,
|
2015-12-06 04:10:52 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2014-02-08 20:27:13 +00:00
|
|
|
static void
|
|
|
|
gtk_action_bar_buildable_add_child (GtkBuildable *buildable,
|
|
|
|
GtkBuilder *builder,
|
|
|
|
GObject *child,
|
|
|
|
const gchar *type)
|
|
|
|
{
|
|
|
|
GtkActionBar *action_bar = GTK_ACTION_BAR (buildable);
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
|
|
|
if (type && strcmp (type, "center") == 0)
|
2014-11-12 04:01:16 +00:00
|
|
|
gtk_box_set_center_widget (GTK_BOX (priv->box), GTK_WIDGET (child));
|
2014-02-08 20:27:13 +00:00
|
|
|
else if (!type)
|
|
|
|
gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
|
|
|
|
else
|
|
|
|
GTK_BUILDER_WARN_INVALID_CHILD_TYPE (action_bar, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkBuildableIface *parent_buildable_iface;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_action_bar_buildable_interface_init (GtkBuildableIface *iface)
|
|
|
|
{
|
|
|
|
parent_buildable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
iface->add_child = gtk_action_bar_buildable_add_child;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_pack_start:
|
|
|
|
* @action_bar: A #GtkActionBar
|
|
|
|
* @child: the #GtkWidget to be added to @action_bar
|
|
|
|
*
|
|
|
|
* Adds @child to @action_bar, packed with reference to the
|
|
|
|
* start of the @action_bar.
|
|
|
|
*
|
|
|
|
* Since: 3.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_action_bar_pack_start (GtkActionBar *action_bar,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
2016-10-02 15:37:22 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (priv->box), child, FALSE, TRUE);
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_pack_end:
|
|
|
|
* @action_bar: A #GtkActionBar
|
|
|
|
* @child: the #GtkWidget to be added to @action_bar
|
|
|
|
*
|
|
|
|
* Adds @child to @action_bar, packed with reference to the
|
|
|
|
* end of the @action_bar.
|
|
|
|
*
|
|
|
|
* Since: 3.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_action_bar_pack_end (GtkActionBar *action_bar,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
2016-10-02 15:37:22 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (priv->box), child, FALSE, TRUE);
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_set_center_widget:
|
|
|
|
* @action_bar: a #GtkActionBar
|
|
|
|
* @center_widget: (allow-none): a widget to use for the center
|
|
|
|
*
|
|
|
|
* Sets the center widget for the #GtkActionBar.
|
|
|
|
*
|
|
|
|
* Since: 3.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_action_bar_set_center_widget (GtkActionBar *action_bar,
|
|
|
|
GtkWidget *center_widget)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
2014-11-12 04:01:16 +00:00
|
|
|
gtk_box_set_center_widget (GTK_BOX (priv->box), center_widget);
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_get_center_widget:
|
|
|
|
* @action_bar: a #GtkActionBar
|
|
|
|
*
|
|
|
|
* Retrieves the center bar widget of the bar.
|
|
|
|
*
|
2015-12-01 12:36:21 +00:00
|
|
|
* Returns: (transfer none) (nullable): the center #GtkWidget or %NULL.
|
2014-02-08 20:27:13 +00:00
|
|
|
*
|
|
|
|
* Since: 3.12
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gtk_action_bar_get_center_widget (GtkActionBar *action_bar)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ACTION_BAR (action_bar), NULL);
|
|
|
|
|
2014-11-12 04:01:16 +00:00
|
|
|
return gtk_box_get_center_widget (GTK_BOX (priv->box));
|
2014-02-08 20:27:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_new:
|
|
|
|
*
|
|
|
|
* Creates a new #GtkActionBar widget.
|
|
|
|
*
|
|
|
|
* Returns: a new #GtkActionBar
|
|
|
|
*
|
|
|
|
* Since: 3.12
|
|
|
|
*/
|
|
|
|
GtkWidget *
|
|
|
|
gtk_action_bar_new (void)
|
|
|
|
{
|
|
|
|
return GTK_WIDGET (g_object_new (GTK_TYPE_ACTION_BAR, NULL));
|
|
|
|
}
|
2017-01-08 13:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_set_revealed:
|
|
|
|
* @action_bar: a #GtkActionBar
|
|
|
|
* @revealed: The new value of the property
|
|
|
|
*
|
|
|
|
* Sets the GtkActionBar:revealed property to @revealed. This will cause
|
|
|
|
* @action_bar to show up with a slide-in transition.
|
|
|
|
*
|
|
|
|
* Note that this settings does not automatically show @action_bar and thus won't
|
|
|
|
* have any effect if it is invisible.
|
|
|
|
*
|
|
|
|
* Since: 3.90
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gtk_action_bar_set_revealed (GtkActionBar *action_bar,
|
|
|
|
gboolean revealed)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_ACTION_BAR (action_bar));
|
|
|
|
|
|
|
|
revealed = !!revealed;
|
2017-01-12 14:14:25 +00:00
|
|
|
if (revealed != gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer)))
|
|
|
|
{
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), revealed);
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (action_bar), props[PROP_REVEALED]);
|
|
|
|
}
|
2017-01-08 13:52:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_action_bar_get_revealed:
|
|
|
|
* @action_bar: a #GtkActionBar
|
|
|
|
*
|
|
|
|
* Returns: the current value of the GtkActionBar:revealed property.
|
|
|
|
*
|
|
|
|
* Since: 3.90
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gtk_action_bar_get_revealed (GtkActionBar *action_bar)
|
|
|
|
{
|
|
|
|
GtkActionBarPrivate *priv = gtk_action_bar_get_instance_private (action_bar);
|
|
|
|
|
|
|
|
g_return_val_if_fail (GTK_IS_ACTION_BAR (action_bar), FALSE);
|
|
|
|
|
|
|
|
return gtk_revealer_get_reveal_child (GTK_REVEALER (priv->revealer));
|
|
|
|
}
|