guint prop_id,
GValue *value,
GParamSpec *pspec);
-static void gtk_separator_tool_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void gtk_separator_tool_item_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
+static void gtk_separator_tool_item_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural);
static void gtk_separator_tool_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-static gboolean gtk_separator_tool_item_expose (GtkWidget *widget,
- GdkEventExpose *event);
+static gboolean gtk_separator_tool_item_draw (GtkWidget *widget,
+ cairo_t *cr);
static void gtk_separator_tool_item_add (GtkContainer *container,
GtkWidget *child);
static gint get_space_size (GtkToolItem *tool_item);
get_space_size (GtkToolItem *tool_item)
{
gint space_size = _gtk_toolbar_get_default_space_size();
- GtkWidget *parent = GTK_WIDGET (tool_item)->parent;
-
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
+
if (GTK_IS_TOOLBAR (parent))
{
gtk_widget_style_get (parent,
object_class->set_property = gtk_separator_tool_item_set_property;
object_class->get_property = gtk_separator_tool_item_get_property;
- widget_class->size_request = gtk_separator_tool_item_size_request;
+ widget_class->get_preferred_width = gtk_separator_tool_item_get_preferred_width;
+ widget_class->get_preferred_height = gtk_separator_tool_item_get_preferred_height;
widget_class->size_allocate = gtk_separator_tool_item_size_allocate;
- widget_class->expose_event = gtk_separator_tool_item_expose;
+ widget_class->draw = gtk_separator_tool_item_draw;
widget_class->realize = gtk_separator_tool_item_realize;
widget_class->unrealize = gtk_separator_tool_item_unrealize;
widget_class->map = gtk_separator_tool_item_map;
static void
gtk_separator_tool_item_init (GtkSeparatorToolItem *separator_item)
{
+ GtkStyleContext *context;
+
separator_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (separator_item,
GTK_TYPE_SEPARATOR_TOOL_ITEM,
GtkSeparatorToolItemPrivate);
separator_item->priv->draw = TRUE;
gtk_widget_set_has_window (GTK_WIDGET (separator_item), FALSE);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (separator_item));
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
}
static void
}
static void
-gtk_separator_tool_item_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
+gtk_separator_tool_item_get_preferred_size (GtkWidget *widget,
+ GtkOrientation orientation,
+ gint *minimum,
+ gint *natural)
{
- GtkToolItem *item = GTK_TOOL_ITEM (widget);
- GtkOrientation orientation = gtk_tool_item_get_orientation (item);
-
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- requisition->width = get_space_size (item);
- requisition->height = 1;
- }
+ if (gtk_tool_item_get_orientation (GTK_TOOL_ITEM (widget)) == orientation)
+ *minimum = *natural = get_space_size (GTK_TOOL_ITEM (widget));
else
- {
- requisition->height = get_space_size (item);
- requisition->width = 1;
- }
+ *minimum = *natural = 1;
+}
+
+static void
+gtk_separator_tool_item_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ gtk_separator_tool_item_get_preferred_size (widget,
+ GTK_ORIENTATION_HORIZONTAL,
+ minimum,
+ natural);
+}
+
+static void
+gtk_separator_tool_item_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ gtk_separator_tool_item_get_preferred_size (widget,
+ GTK_ORIENTATION_VERTICAL,
+ minimum,
+ natural);
}
static void
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
GtkSeparatorToolItemPrivate *priv = separator->priv;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (priv->event_window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
}
static void
gtk_separator_tool_item_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
GtkSeparatorToolItemPrivate *priv = separator->priv;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.visual = gtk_widget_get_visual (widget);
- attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget) |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
}
static void
}
static gboolean
-gtk_separator_tool_item_expose (GtkWidget *widget,
- GdkEventExpose *event)
+gtk_separator_tool_item_draw (GtkWidget *widget,
+ cairo_t *cr)
{
+ GtkAllocation allocation;
GtkToolbar *toolbar = NULL;
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
GtkSeparatorToolItemPrivate *priv = separator->priv;
+ GtkWidget *parent;
if (priv->draw)
{
- if (GTK_IS_TOOLBAR (widget->parent))
- toolbar = GTK_TOOLBAR (widget->parent);
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_TOOLBAR (parent))
+ toolbar = GTK_TOOLBAR (parent);
- _gtk_toolbar_paint_space_line (widget, toolbar,
- &(event->area), &widget->allocation);
+ gtk_widget_get_allocation (widget, &allocation);
+ _gtk_toolbar_paint_space_line (widget, toolbar, cr);
}
return FALSE;