mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-10-01 11:37:35 +00:00
separator: Convert to draw signal
This commit is contained in:
parent
812d9b9948
commit
84671438b0
@ -64,8 +64,8 @@ static void gtk_separator_get_property (GObject *object,
|
|||||||
|
|
||||||
static void gtk_separator_size_request (GtkWidget *widget,
|
static void gtk_separator_size_request (GtkWidget *widget,
|
||||||
GtkRequisition *requisition);
|
GtkRequisition *requisition);
|
||||||
static gboolean gtk_separator_expose (GtkWidget *widget,
|
static gboolean gtk_separator_draw (GtkWidget *widget,
|
||||||
GdkEventExpose *event);
|
cairo_t *cr);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET,
|
G_DEFINE_TYPE_WITH_CODE (GtkSeparator, gtk_separator, GTK_TYPE_WIDGET,
|
||||||
@ -83,7 +83,7 @@ gtk_separator_class_init (GtkSeparatorClass *class)
|
|||||||
object_class->get_property = gtk_separator_get_property;
|
object_class->get_property = gtk_separator_get_property;
|
||||||
|
|
||||||
widget_class->size_request = gtk_separator_size_request;
|
widget_class->size_request = gtk_separator_size_request;
|
||||||
widget_class->expose_event = gtk_separator_expose;
|
widget_class->draw = gtk_separator_draw;
|
||||||
|
|
||||||
g_object_class_override_property (object_class,
|
g_object_class_override_property (object_class,
|
||||||
PROP_ORIENTATION,
|
PROP_ORIENTATION,
|
||||||
@ -186,21 +186,18 @@ gtk_separator_size_request (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_separator_expose (GtkWidget *widget,
|
gtk_separator_draw (GtkWidget *widget,
|
||||||
GdkEventExpose *event)
|
cairo_t *cr)
|
||||||
{
|
{
|
||||||
GtkSeparator *separator = GTK_SEPARATOR (widget);
|
GtkSeparator *separator = GTK_SEPARATOR (widget);
|
||||||
GtkSeparatorPrivate *private = separator->priv;
|
GtkSeparatorPrivate *private = separator->priv;
|
||||||
GtkAllocation allocation;
|
|
||||||
GtkStateType state;
|
GtkStateType state;
|
||||||
GtkStyle *style;
|
GtkStyle *style;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
gboolean wide_separators;
|
gboolean wide_separators;
|
||||||
gint separator_width;
|
gint separator_width;
|
||||||
gint separator_height;
|
gint separator_height;
|
||||||
|
int width, height;
|
||||||
if (!gtk_widget_is_drawable (widget))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
style = gtk_widget_get_style (widget);
|
style = gtk_widget_get_style (widget);
|
||||||
gtk_widget_style_get (widget,
|
gtk_widget_style_get (widget,
|
||||||
@ -211,43 +208,38 @@ gtk_separator_expose (GtkWidget *widget,
|
|||||||
|
|
||||||
window = gtk_widget_get_window (widget);
|
window = gtk_widget_get_window (widget);
|
||||||
state = gtk_widget_get_state (widget);
|
state = gtk_widget_get_state (widget);
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
width = gtk_widget_get_allocated_width (widget);
|
||||||
|
height = gtk_widget_get_allocated_height (widget);
|
||||||
|
|
||||||
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
|
||||||
{
|
{
|
||||||
if (wide_separators)
|
if (wide_separators)
|
||||||
gtk_paint_box (style, window,
|
gtk_cairo_paint_box (style, cr,
|
||||||
state, GTK_SHADOW_ETCHED_OUT,
|
gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT,
|
||||||
&event->area, widget, "hseparator",
|
widget, "hseparator",
|
||||||
allocation.x,
|
0, (height - separator_height) / 2,
|
||||||
allocation.y + (allocation.height - separator_height) / 2,
|
width, separator_height);
|
||||||
allocation.width,
|
|
||||||
separator_height);
|
|
||||||
else
|
else
|
||||||
gtk_paint_hline (style, window,
|
gtk_cairo_paint_hline (style, cr,
|
||||||
state,
|
gtk_widget_get_state (widget),
|
||||||
&event->area, widget, "hseparator",
|
widget, "hseparator",
|
||||||
allocation.x,
|
0, width - 1,
|
||||||
allocation.x + allocation.width - 1,
|
(height - style->ythickness) / 2);
|
||||||
allocation.y + (allocation.height - style->ythickness) / 2);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (wide_separators)
|
if (wide_separators)
|
||||||
gtk_paint_box (style, window,
|
gtk_cairo_paint_box (style, cr,
|
||||||
state, GTK_SHADOW_ETCHED_OUT,
|
gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT,
|
||||||
&event->area, widget, "vseparator",
|
widget, "vseparator",
|
||||||
allocation.x + (allocation.width - separator_width) / 2,
|
(width - separator_width) / 2, 0,
|
||||||
allocation.y,
|
separator_width, height);
|
||||||
separator_width,
|
|
||||||
allocation.height);
|
|
||||||
else
|
else
|
||||||
gtk_paint_vline (style, window,
|
gtk_cairo_paint_vline (style, cr,
|
||||||
state,
|
gtk_widget_get_state (widget),
|
||||||
&event->area, widget, "vseparator",
|
widget, "vseparator",
|
||||||
allocation.y,
|
0, height - 1,
|
||||||
allocation.y + allocation.height - 1,
|
(width - style->xthickness) / 2);
|
||||||
allocation.x + (allocation.width - style->xthickness) / 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
Reference in New Issue
Block a user