* Boston, MA 02111-1307, USA.
*/
-#undef GTK_DISABLE_DEPRECATED
-
+#include "config.h"
#include "gtkseparatormenuitem.h"
#include "gtkseparatortoolitem.h"
#include "gtkintl.h"
#include "gtktoolbar.h"
-
-/* note: keep in sync with DEFAULT_SPACE_SIZE and DEFAULT_SPACE_STYLE in gtktoolbar.c */
-#define DEFAULT_SPACE_SIZE 4
-#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE
-
-#define SPACE_LINE_DIVISION 10
-#define SPACE_LINE_START 3
-#define SPACE_LINE_END 7
+#include "gtkprivate.h"
+#include "gtkalias.h"
#define MENU_ID "gtk-separator-tool-item-menu-id"
PROP_DRAW
};
-static void gtk_separator_tool_item_class_init (GtkSeparatorToolItemClass *class);
-static void gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item,
- GtkSeparatorToolItemClass *class);
static gboolean gtk_separator_tool_item_create_menu_proxy (GtkToolItem *item);
static void gtk_separator_tool_item_set_property (GObject *object,
guint prop_id,
GdkEventExpose *event);
static void gtk_separator_tool_item_add (GtkContainer *container,
GtkWidget *child);
-static GtkToolbarSpaceStyle get_space_style (GtkToolItem *tool_item);
-static gint get_space_size (GtkToolItem *tool_item);
+static gint get_space_size (GtkToolItem *tool_item);
-static GObjectClass *parent_class = NULL;
-
#define GTK_SEPARATOR_TOOL_ITEM_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_SEPARATOR_TOOL_ITEM, GtkSeparatorToolItemPrivate))
struct _GtkSeparatorToolItemPrivate
guint draw : 1;
};
-GType
-gtk_separator_tool_item_get_type (void)
-{
- static GType type = 0;
-
- if (!type)
- {
- static const GTypeInfo type_info =
- {
- sizeof (GtkSeparatorToolItemClass),
- (GBaseInitFunc) 0,
- (GBaseFinalizeFunc) 0,
- (GClassInitFunc) gtk_separator_tool_item_class_init,
- (GClassFinalizeFunc) 0,
- NULL,
- sizeof (GtkSeparatorToolItem),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gtk_separator_tool_item_init,
- };
-
- type = g_type_register_static (GTK_TYPE_TOOL_ITEM,
- "GtkSeparatorToolItem", &type_info, 0);
- }
- return type;
-}
-
-static GtkToolbarSpaceStyle
-get_space_style (GtkToolItem *tool_item)
-{
- GtkToolbarSpaceStyle space_style = DEFAULT_SPACE_STYLE;
- GtkWidget *parent = GTK_WIDGET (tool_item)->parent;
-
- if (GTK_IS_TOOLBAR (parent))
- {
- gtk_widget_style_get (parent,
- "space_style", &space_style,
- NULL);
- }
-
- return space_style;
-}
+G_DEFINE_TYPE (GtkSeparatorToolItem, gtk_separator_tool_item, GTK_TYPE_TOOL_ITEM)
static gint
get_space_size (GtkToolItem *tool_item)
{
- gint space_size = DEFAULT_SPACE_SIZE;
+ gint space_size = _gtk_toolbar_get_default_space_size();
GtkWidget *parent = GTK_WIDGET (tool_item)->parent;
if (GTK_IS_TOOLBAR (parent))
{
gtk_widget_style_get (parent,
- "space_size", &space_size,
+ "space-size", &space_size,
NULL);
}
GtkToolItemClass *toolitem_class;
GtkWidgetClass *widget_class;
- parent_class = g_type_class_peek_parent (class);
object_class = (GObjectClass *)class;
container_class = (GtkContainerClass *)class;
toolitem_class = (GtkToolItemClass *)class;
P_("Draw"),
P_("Whether the separator is drawn, or just blank"),
TRUE,
- G_PARAM_READWRITE));
+ GTK_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (GtkSeparatorToolItemPrivate));
}
static void
-gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item,
- GtkSeparatorToolItemClass *class)
+gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item)
{
separator_item->priv = GTK_SEPARATOR_TOOL_ITEM_GET_PRIVATE (separator_item);
separator_item->priv->draw = TRUE;
gtk_separator_tool_item_add (GtkContainer *container,
GtkWidget *child)
{
- g_warning("attempt to add a child to an GtkSeparatorToolItem");
+ g_warning ("attempt to add a child to an GtkSeparatorToolItem");
}
static gboolean
gtk_separator_tool_item_expose (GtkWidget *widget,
GdkEventExpose *event)
{
- GtkToolItem *tool_item = GTK_TOOL_ITEM (widget);
- GtkSeparatorToolItem *separator_tool_item = GTK_SEPARATOR_TOOL_ITEM (widget);
- gint space_size;
- GtkAllocation *allocation;
- GtkOrientation orientation;
- GdkRectangle *area;
+ GtkToolbar *toolbar = NULL;
+ GtkSeparatorToolItemPrivate *priv =
+ GTK_SEPARATOR_TOOL_ITEM_GET_PRIVATE (widget);
- if (separator_tool_item->priv->draw &&
- get_space_style (tool_item) == GTK_TOOLBAR_SPACE_LINE)
+ if (priv->draw)
{
- space_size = get_space_size (tool_item);
- allocation = &(widget->allocation);
- orientation = gtk_tool_item_get_orientation (tool_item);
- area = &(event->area);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- gtk_paint_vline (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), area, widget,
- "separator_tool_item",
- allocation->y + allocation->height *
- SPACE_LINE_START / SPACE_LINE_DIVISION,
- allocation->y + allocation->height *
- SPACE_LINE_END / SPACE_LINE_DIVISION,
- allocation->x + (space_size - widget->style->xthickness) / 2);
- }
- else if (orientation == GTK_ORIENTATION_VERTICAL)
- {
- gtk_paint_hline (widget->style, widget->window,
- GTK_WIDGET_STATE (widget), area, widget,
- "separator_tool_item",
- allocation->x + allocation->width *
- SPACE_LINE_START / SPACE_LINE_DIVISION,
- allocation->x + allocation->width *
- SPACE_LINE_END / SPACE_LINE_DIVISION,
- allocation->y + (space_size - widget->style->ythickness) / 2);
- }
+ if (GTK_IS_TOOLBAR (widget->parent))
+ toolbar = GTK_TOOLBAR (widget->parent);
+
+ _gtk_toolbar_paint_space_line (widget, toolbar,
+ &(event->area), &widget->allocation);
}
return FALSE;
* Return value: the new #GtkSeparatorToolItem
*
* Since: 2.4
- **/
+ */
GtkToolItem *
gtk_separator_tool_item_new (void)
{
/**
* gtk_separator_tool_item_get_draw:
- * @separator_tool_item: a #GtkSeparatorToolItem
+ * @item: a #GtkSeparatorToolItem
*
- * Returns whether @separator_tool_item is drawn as a
- * line, or just blank. See gtk_separator_tool_item_set_draw().
+ * Returns whether @item is drawn as a line, or just blank.
+ * See gtk_separator_tool_item_set_draw().
*
- * Return value: #TRUE if @separator_tool_item is drawn as a line, or just blank.
+ * Return value: %TRUE if @item is drawn as a line, or just blank.
*
* Since: 2.4
- **/
+ */
gboolean
-gtk_separator_tool_item_get_draw (GtkSeparatorToolItem *separator_tool_item)
+gtk_separator_tool_item_get_draw (GtkSeparatorToolItem *item)
{
- g_return_val_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (separator_tool_item), FALSE);
+ g_return_val_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item), FALSE);
- return separator_tool_item->priv->draw;
+ return item->priv->draw;
}
/**
* gtk_separator_tool_item_set_draw:
- * @separator_tool_item: a #GtkSeparatorToolItem
- * @draw: whether @separator_tool_item is drawn as a vertical iln
+ * @item: a #GtkSeparatorToolItem
+ * @draw: whether @item is drawn as a vertical line
*
- * When @separator_tool_items is drawn as a vertical line, or just blank.
- * Setting this #FALSE along with gtk_tool_item_set_expand() is useful
+ * Whether @item is drawn as a vertical line, or just blank.
+ * Setting this to %FALSE along with gtk_tool_item_set_expand() is useful
* to create an item that forces following items to the end of the toolbar.
*
* Since: 2.4
- **/
+ */
void
-gtk_separator_tool_item_set_draw (GtkSeparatorToolItem *separator_tool_item,
+gtk_separator_tool_item_set_draw (GtkSeparatorToolItem *item,
gboolean draw)
{
- g_return_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (separator_tool_item));
+ g_return_if_fail (GTK_IS_SEPARATOR_TOOL_ITEM (item));
draw = draw != FALSE;
- if (draw != separator_tool_item->priv->draw)
+ if (draw != item->priv->draw)
{
- separator_tool_item->priv->draw = draw;
+ item->priv->draw = draw;
- gtk_widget_queue_draw (GTK_WIDGET (separator_tool_item));
+ gtk_widget_queue_draw (GTK_WIDGET (item));
- g_object_notify (G_OBJECT (separator_tool_item), "draw");
+ g_object_notify (G_OBJECT (item), "draw");
}
}
+#define __GTK_SEPARATOR_TOOL_ITEM_C__
+#include "gtkaliasdef.c"