2003-06-29 23:34:20 +00:00
|
|
|
/* gtkseparatortoolitem.c
|
|
|
|
*
|
2003-12-29 10:55:53 +00:00
|
|
|
* Copyright (C) 2002 Anders Carlsson <andersca@gnome.org>
|
2003-06-29 23:34:20 +00:00
|
|
|
* Copyright (C) 2002 James Henstridge <james@daa.com.au>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2003-06-29 23:34:20 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
2003-06-29 23:34:20 +00:00
|
|
|
#include "gtkseparatormenuitem.h"
|
|
|
|
#include "gtkseparatortoolitem.h"
|
|
|
|
#include "gtkintl.h"
|
2014-04-05 06:04:12 +00:00
|
|
|
#include "gtktoolbarprivate.h"
|
2005-03-22 02:14:55 +00:00
|
|
|
#include "gtkprivate.h"
|
2015-12-09 02:14:00 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
|
|
|
#include "gtkcsscustomgadgetprivate.h"
|
2010-05-16 00:31:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:gtkseparatortoolitem
|
|
|
|
* @Short_description: A toolbar item that separates groups of other
|
|
|
|
* toolbar items
|
|
|
|
* @Title: GtkSeparatorToolItem
|
|
|
|
* @See_also: #GtkToolbar, #GtkRadioToolButton
|
|
|
|
*
|
2012-07-02 06:19:06 +00:00
|
|
|
* A #GtkSeparatorToolItem is a #GtkToolItem that separates groups of other
|
2010-05-16 00:31:45 +00:00
|
|
|
* #GtkToolItems. Depending on the theme, a #GtkSeparatorToolItem will
|
|
|
|
* often look like a vertical line on horizontally docked toolbars.
|
|
|
|
*
|
2014-02-05 18:07:34 +00:00
|
|
|
* If the #GtkToolbar child property “expand” is %TRUE and the property
|
2010-05-16 00:31:45 +00:00
|
|
|
* #GtkSeparatorToolItem:draw is %FALSE, a #GtkSeparatorToolItem will act as
|
2014-02-05 18:07:34 +00:00
|
|
|
* a “spring” that forces other items to the ends of the toolbar.
|
2010-05-16 00:31:45 +00:00
|
|
|
*
|
|
|
|
* Use gtk_separator_tool_item_new() to create a new #GtkSeparatorToolItem.
|
2015-11-05 20:41:37 +00:00
|
|
|
*
|
|
|
|
* # CSS nodes
|
|
|
|
*
|
|
|
|
* GtkSeparatorToolItem has a single CSS node with name separator.
|
2010-05-16 00:31:45 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-04 21:13:55 +00:00
|
|
|
#define MENU_ID "gtk-separator-tool-item-menu-id"
|
|
|
|
|
2010-07-12 18:26:22 +00:00
|
|
|
struct _GtkSeparatorToolItemPrivate
|
|
|
|
{
|
2015-12-09 02:14:00 +00:00
|
|
|
GtkCssGadget *gadget;
|
2010-07-16 05:15:47 +00:00
|
|
|
GdkWindow *event_window;
|
2010-07-12 18:26:22 +00:00
|
|
|
guint draw : 1;
|
|
|
|
};
|
|
|
|
|
2003-10-25 19:58:51 +00:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_DRAW
|
|
|
|
};
|
|
|
|
|
|
|
|
static gboolean gtk_separator_tool_item_create_menu_proxy (GtkToolItem *item);
|
|
|
|
static void gtk_separator_tool_item_set_property (GObject *object,
|
2010-07-16 05:15:47 +00:00
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gtk_separator_tool_item_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2016-10-22 14:06:14 +00:00
|
|
|
static void gtk_separator_tool_item_measure (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
gint for_size,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural,
|
|
|
|
gint *minimum_baseline,
|
|
|
|
gint *natural_baseline);
|
2010-07-16 05:15:47 +00:00
|
|
|
static void gtk_separator_tool_item_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
2010-09-06 14:20:30 +00:00
|
|
|
static gboolean gtk_separator_tool_item_draw (GtkWidget *widget,
|
|
|
|
cairo_t *cr);
|
2003-10-25 19:58:51 +00:00
|
|
|
static void gtk_separator_tool_item_add (GtkContainer *container,
|
2010-07-16 05:15:47 +00:00
|
|
|
GtkWidget *child);
|
|
|
|
static void gtk_separator_tool_item_realize (GtkWidget *widget);
|
|
|
|
static void gtk_separator_tool_item_unrealize (GtkWidget *widget);
|
|
|
|
static void gtk_separator_tool_item_map (GtkWidget *widget);
|
|
|
|
static void gtk_separator_tool_item_unmap (GtkWidget *widget);
|
|
|
|
static gboolean gtk_separator_tool_item_button_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event);
|
2014-03-02 20:49:35 +00:00
|
|
|
static gboolean gtk_separator_tool_item_motion_event (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event);
|
2003-10-25 19:58:51 +00:00
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM)
|
2003-06-29 23:34:20 +00:00
|
|
|
|
2015-12-09 02:14:00 +00:00
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *item = GTK_SEPARATOR_TOOL_ITEM (object);
|
|
|
|
|
|
|
|
g_clear_object (&item->priv->gadget);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_separator_tool_item_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2003-06-29 23:34:20 +00:00
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class)
|
|
|
|
{
|
2003-10-25 19:58:51 +00:00
|
|
|
GObjectClass *object_class;
|
2003-06-29 23:34:20 +00:00
|
|
|
GtkContainerClass *container_class;
|
|
|
|
GtkToolItemClass *toolitem_class;
|
2003-07-07 14:35:31 +00:00
|
|
|
GtkWidgetClass *widget_class;
|
2003-10-25 19:58:51 +00:00
|
|
|
|
|
|
|
object_class = (GObjectClass *)class;
|
2003-06-29 23:34:20 +00:00
|
|
|
container_class = (GtkContainerClass *)class;
|
|
|
|
toolitem_class = (GtkToolItemClass *)class;
|
2003-07-07 14:35:31 +00:00
|
|
|
widget_class = (GtkWidgetClass *)class;
|
2003-06-29 23:34:20 +00:00
|
|
|
|
2003-10-25 19:58:51 +00:00
|
|
|
object_class->set_property = gtk_separator_tool_item_set_property;
|
|
|
|
object_class->get_property = gtk_separator_tool_item_get_property;
|
2015-12-09 02:14:00 +00:00
|
|
|
object_class->finalize = gtk_separator_tool_item_finalize;
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
widget_class->measure = gtk_separator_tool_item_measure;
|
2010-07-16 05:15:47 +00:00
|
|
|
widget_class->size_allocate = gtk_separator_tool_item_size_allocate;
|
2010-09-06 14:20:30 +00:00
|
|
|
widget_class->draw = gtk_separator_tool_item_draw;
|
2010-07-16 05:15:47 +00:00
|
|
|
widget_class->realize = gtk_separator_tool_item_realize;
|
|
|
|
widget_class->unrealize = gtk_separator_tool_item_unrealize;
|
|
|
|
widget_class->map = gtk_separator_tool_item_map;
|
|
|
|
widget_class->unmap = gtk_separator_tool_item_unmap;
|
|
|
|
widget_class->button_press_event = gtk_separator_tool_item_button_event;
|
|
|
|
widget_class->button_release_event = gtk_separator_tool_item_button_event;
|
2014-03-02 20:49:35 +00:00
|
|
|
widget_class->motion_notify_event = gtk_separator_tool_item_motion_event;
|
2010-07-16 05:15:47 +00:00
|
|
|
|
2003-08-04 21:13:55 +00:00
|
|
|
toolitem_class->create_menu_proxy = gtk_separator_tool_item_create_menu_proxy;
|
2003-10-25 19:58:51 +00:00
|
|
|
|
2003-06-29 23:34:20 +00:00
|
|
|
container_class->add = gtk_separator_tool_item_add;
|
2003-10-25 19:58:51 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class,
|
2010-07-16 05:15:47 +00:00
|
|
|
PROP_DRAW,
|
|
|
|
g_param_spec_boolean ("draw",
|
|
|
|
P_("Draw"),
|
|
|
|
P_("Whether the separator is drawn, or just blank"),
|
|
|
|
TRUE,
|
2014-06-09 13:40:06 +00:00
|
|
|
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
|
2015-11-05 20:41:37 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_css_name (widget_class, "separator");
|
2003-10-25 19:58:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-07-16 05:15:47 +00:00
|
|
|
gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item)
|
2003-10-25 19:58:51 +00:00
|
|
|
{
|
2015-12-29 20:14:02 +00:00
|
|
|
GtkSeparatorToolItemPrivate *priv;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkCssNode *widget_node;
|
|
|
|
|
|
|
|
widget = GTK_WIDGET (separator_item);
|
|
|
|
priv = separator_item->priv = gtk_separator_tool_item_get_instance_private (separator_item);
|
|
|
|
priv->draw = TRUE;
|
|
|
|
|
|
|
|
gtk_widget_set_has_window (widget, FALSE);
|
|
|
|
|
|
|
|
widget_node = gtk_widget_get_css_node (widget);
|
|
|
|
separator_item->priv->gadget =
|
|
|
|
gtk_css_custom_gadget_new_for_node (widget_node,
|
|
|
|
widget,
|
2015-12-29 20:34:16 +00:00
|
|
|
NULL, NULL, NULL,
|
2016-11-13 20:08:34 +00:00
|
|
|
NULL,
|
2015-12-29 20:34:16 +00:00
|
|
|
NULL, NULL);
|
2003-06-29 23:34:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_add (GtkContainer *container,
|
2010-07-16 05:15:47 +00:00
|
|
|
GtkWidget *child)
|
2003-06-29 23:34:20 +00:00
|
|
|
{
|
2004-01-18 14:31:00 +00:00
|
|
|
g_warning ("attempt to add a child to an GtkSeparatorToolItem");
|
2003-06-29 23:34:20 +00:00
|
|
|
}
|
|
|
|
|
2003-08-04 21:13:55 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_separator_tool_item_create_menu_proxy (GtkToolItem *item)
|
|
|
|
{
|
|
|
|
GtkWidget *menu_item = NULL;
|
|
|
|
|
2015-11-05 20:41:37 +00:00
|
|
|
menu_item = gtk_separator_menu_item_new ();
|
2003-08-04 21:13:55 +00:00
|
|
|
|
|
|
|
gtk_tool_item_set_proxy_menu_item (item, MENU_ID, menu_item);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-25 19:58:51 +00:00
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_set_property (GObject *object,
|
2010-07-16 05:15:47 +00:00
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2003-10-25 19:58:51 +00:00
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *item = GTK_SEPARATOR_TOOL_ITEM (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_DRAW:
|
|
|
|
gtk_separator_tool_item_set_draw (item, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_get_property (GObject *object,
|
2010-07-16 05:15:47 +00:00
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2003-10-25 19:58:51 +00:00
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *item = GTK_SEPARATOR_TOOL_ITEM (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_DRAW:
|
|
|
|
g_value_set_boolean (value, gtk_separator_tool_item_get_draw (item));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-10-27 14:17:58 +00:00
|
|
|
static void
|
2016-10-22 14:06:14 +00:00
|
|
|
gtk_separator_tool_item_measure (GtkWidget *widget,
|
|
|
|
GtkOrientation orientation,
|
|
|
|
gint for_size,
|
|
|
|
gint *minimum,
|
|
|
|
gint *natural,
|
|
|
|
gint *minimum_baseline,
|
|
|
|
gint *natural_baseline)
|
2010-10-27 14:17:58 +00:00
|
|
|
{
|
2015-12-09 02:14:00 +00:00
|
|
|
gtk_css_gadget_get_preferred_size (GTK_SEPARATOR_TOOL_ITEM (widget)->priv->gadget,
|
2016-10-22 14:06:14 +00:00
|
|
|
orientation,
|
|
|
|
for_size,
|
2015-12-09 02:14:00 +00:00
|
|
|
minimum, natural,
|
2016-10-22 14:06:14 +00:00
|
|
|
minimum_baseline, natural_baseline);
|
2003-07-08 18:20:45 +00:00
|
|
|
}
|
|
|
|
|
2010-07-16 05:15:47 +00:00
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
2015-12-09 02:14:00 +00:00
|
|
|
GtkAllocation clip;
|
2010-07-16 05:15:47 +00:00
|
|
|
|
2010-08-11 21:01:01 +00:00
|
|
|
gtk_widget_set_allocation (widget, allocation);
|
2010-07-16 05:15:47 +00:00
|
|
|
|
|
|
|
if (gtk_widget_get_realized (widget))
|
|
|
|
gdk_window_move_resize (priv->event_window,
|
2010-08-11 21:01:01 +00:00
|
|
|
allocation->x,
|
|
|
|
allocation->y,
|
|
|
|
allocation->width,
|
|
|
|
allocation->height);
|
2010-07-16 05:15:47 +00:00
|
|
|
|
2015-12-09 02:14:00 +00:00
|
|
|
gtk_css_gadget_allocate (priv->gadget,
|
|
|
|
allocation,
|
|
|
|
gtk_widget_get_allocated_baseline (widget),
|
|
|
|
&clip);
|
|
|
|
|
|
|
|
gtk_widget_set_clip (widget, &clip);
|
2010-07-16 05:15:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_realize (GtkWidget *widget)
|
|
|
|
{
|
2010-08-11 21:01:01 +00:00
|
|
|
GtkAllocation allocation;
|
2010-07-16 05:15:47 +00:00
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
2010-08-11 21:01:01 +00:00
|
|
|
GdkWindow *window;
|
2010-07-16 05:15:47 +00:00
|
|
|
|
|
|
|
gtk_widget_set_realized (widget, TRUE);
|
|
|
|
|
2010-08-11 21:01:01 +00:00
|
|
|
gtk_widget_get_allocation (widget, &allocation);
|
|
|
|
|
|
|
|
window = gtk_widget_get_parent_window (widget);
|
|
|
|
gtk_widget_set_window (widget, window);
|
|
|
|
g_object_ref (window);
|
2010-07-16 05:15:47 +00:00
|
|
|
|
2016-10-17 22:22:04 +00:00
|
|
|
priv->event_window = gdk_window_new_input (gtk_widget_get_parent_window (widget),
|
|
|
|
gtk_widget_get_events (widget)
|
|
|
|
| GDK_BUTTON_PRESS_MASK
|
|
|
|
| GDK_BUTTON_RELEASE_MASK
|
|
|
|
| GDK_POINTER_MOTION_MASK,
|
|
|
|
&allocation);
|
2013-02-05 08:36:49 +00:00
|
|
|
gtk_widget_register_window (widget, priv->event_window);
|
2010-07-16 05:15:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_unrealize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
|
|
|
|
|
|
|
if (priv->event_window)
|
|
|
|
{
|
2013-02-05 08:36:49 +00:00
|
|
|
gtk_widget_unregister_window (widget, priv->event_window);
|
2010-07-16 05:15:47 +00:00
|
|
|
gdk_window_destroy (priv->event_window);
|
|
|
|
priv->event_window = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_separator_tool_item_parent_class)->unrealize (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_map (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_separator_tool_item_parent_class)->map (widget);
|
|
|
|
|
|
|
|
if (priv->event_window)
|
|
|
|
gdk_window_show (priv->event_window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_separator_tool_item_unmap (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
|
|
|
|
|
|
|
if (priv->event_window)
|
|
|
|
gdk_window_hide (priv->event_window);
|
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (gtk_separator_tool_item_parent_class)->unmap (widget);
|
|
|
|
}
|
|
|
|
|
2014-03-02 20:49:35 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_separator_tool_item_motion_event (GtkWidget *widget,
|
|
|
|
GdkEventMotion *event)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
|
|
|
|
|
|
|
/* We want window dragging to work on empty toolbar areas,
|
|
|
|
* so we only eat button events on visible separators
|
|
|
|
*/
|
|
|
|
return priv->draw;
|
|
|
|
}
|
|
|
|
|
2010-07-16 05:15:47 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_separator_tool_item_button_event (GtkWidget *widget,
|
|
|
|
GdkEventButton *event)
|
|
|
|
{
|
|
|
|
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
|
|
|
|
GtkSeparatorToolItemPrivate *priv = separator->priv;
|
|
|
|
|
|
|
|
/* We want window dragging to work on empty toolbar areas,
|
|
|
|
* so we only eat button events on visible separators
|
|
|
|
*/
|
|
|
|
return priv->draw;
|
|
|
|
}
|
|
|
|
|
2003-07-07 14:35:31 +00:00
|
|
|
static gboolean
|
2010-09-06 14:20:30 +00:00
|
|
|
gtk_separator_tool_item_draw (GtkWidget *widget,
|
|
|
|
cairo_t *cr)
|
2003-07-07 14:35:31 +00:00
|
|
|
{
|
2016-01-03 01:53:54 +00:00
|
|
|
if (GTK_SEPARATOR_TOOL_ITEM (widget)->priv->draw)
|
|
|
|
gtk_css_gadget_draw (GTK_SEPARATOR_TOOL_ITEM (widget)->priv->gadget, cr);
|
2010-07-16 05:15:47 +00:00
|
|
|
|
2003-10-25 19:58:51 +00:00
|
|
|
return FALSE;
|
2003-07-07 14:35:31 +00:00
|
|
|
}
|
|
|
|
|
2003-08-04 21:13:55 +00:00
|
|
|
/**
|
|
|
|
* gtk_separator_tool_item_new:
|
|
|
|
*
|
|
|
|
* Create a new #GtkSeparatorToolItem
|
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: the new #GtkSeparatorToolItem
|
2003-08-04 21:13:55 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
2008-12-29 00:07:32 +00:00
|
|
|
*/
|
2003-06-29 23:34:20 +00:00
|
|
|
GtkToolItem *
|
|
|
|
gtk_separator_tool_item_new (void)
|
|
|
|
{
|
|
|
|
GtkToolItem *self;
|
2003-10-25 19:58:51 +00:00
|
|
|
|
2003-06-29 23:34:20 +00:00
|
|
|
self = g_object_new (GTK_TYPE_SEPARATOR_TOOL_ITEM,
|
2010-07-16 05:15:47 +00:00
|
|
|
NULL);
|
2003-06-29 23:34:20 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
2003-10-25 19:58:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_separator_tool_item_get_draw:
|
2004-01-22 23:47:42 +00:00
|
|
|
* @item: a #GtkSeparatorToolItem
|
2003-10-25 19:58:51 +00:00
|
|
|
*
|
2008-12-29 00:07:32 +00:00
|
|
|
* Returns whether @item is drawn as a line, or just blank.
|
|
|
|
* See gtk_separator_tool_item_set_draw().
|
2003-10-25 19:58:51 +00:00
|
|
|
*
|
2014-02-19 23:49:43 +00:00
|
|
|
* Returns: %TRUE if @item is drawn as a line, or just blank.
|
2003-10-25 19:58:51 +00:00
|
|
|
*
|
|
|
|
* Since: 2.4
|
2008-12-29 00:07:32 +00:00
|
|
|
*/
|
2003-10-25 19:58:51 +00:00
|
|
|
gboolean
|
2004-01-22 23:47:42 +00:00
|
|
|
gtk_separator_tool_item_get_draw (GtkSeparatorToolItem *item)
|
2003-10-25 19:58:51 +00:00
|
|
|
{
|
2004-01-22 23:47:42 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item), FALSE);
|
2003-10-25 19:58:51 +00:00
|
|
|
|
2004-01-22 23:47:42 +00:00
|
|
|
return item->priv->draw;
|
2003-10-25 19:58:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_separator_tool_item_set_draw:
|
2004-01-22 23:47:42 +00:00
|
|
|
* @item: a #GtkSeparatorToolItem
|
2008-12-29 00:07:32 +00:00
|
|
|
* @draw: whether @item is drawn as a vertical line
|
2003-10-25 19:58:51 +00:00
|
|
|
*
|
2008-12-29 00:07:32 +00:00
|
|
|
* Whether @item is drawn as a vertical line, or just blank.
|
|
|
|
* Setting this to %FALSE along with gtk_tool_item_set_expand() is useful
|
2003-10-25 19:58:51 +00:00
|
|
|
* to create an item that forces following items to the end of the toolbar.
|
|
|
|
*
|
|
|
|
* Since: 2.4
|
2008-12-29 00:07:32 +00:00
|
|
|
*/
|
2003-10-25 19:58:51 +00:00
|
|
|
void
|
2004-01-22 23:47:42 +00:00
|
|
|
gtk_separator_tool_item_set_draw (GtkSeparatorToolItem *item,
|
2010-07-16 05:15:47 +00:00
|
|
|
gboolean draw)
|
2003-10-25 19:58:51 +00:00
|
|
|
{
|
2004-01-22 23:47:42 +00:00
|
|
|
g_return_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item));
|
2003-10-25 19:58:51 +00:00
|
|
|
|
|
|
|
draw = draw != FALSE;
|
|
|
|
|
2004-01-22 23:47:42 +00:00
|
|
|
if (draw != item->priv->draw)
|
2003-10-25 19:58:51 +00:00
|
|
|
{
|
2004-01-22 23:47:42 +00:00
|
|
|
item->priv->draw = draw;
|
2015-12-29 20:34:16 +00:00
|
|
|
if (draw)
|
|
|
|
gtk_css_gadget_remove_class (item->priv->gadget, "invisible");
|
|
|
|
else
|
|
|
|
gtk_css_gadget_add_class (item->priv->gadget, "invisible");
|
2003-10-25 19:58:51 +00:00
|
|
|
|
2004-01-22 23:47:42 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (item));
|
2003-10-25 19:58:51 +00:00
|
|
|
|
2004-01-22 23:47:42 +00:00
|
|
|
g_object_notify (G_OBJECT (item), "draw");
|
2003-10-25 19:58:51 +00:00
|
|
|
}
|
|
|
|
}
|