42
43
G_DEFINE_TYPE (PanelSeparator, panel_separator, GTK_TYPE_EVENT_BOX)
45
panel_separator_paint (GtkWidget *widget,
46
panel_separator_draw (GtkWidget *widget,
48
PanelSeparator *separator;
51
GtkAllocation allocation;
49
PanelSeparator *separator = PANEL_SEPARATOR (widget);
51
GtkStyleContext *context;
53
separator = PANEL_SEPARATOR (widget);
56
if (GTK_WIDGET_CLASS (panel_separator_parent_class)->draw)
57
GTK_WIDGET_CLASS (panel_separator_parent_class)->draw (widget, cr);
55
59
window = gtk_widget_get_window (widget);
56
style = gtk_widget_get_style (widget);
57
gtk_widget_get_allocation (widget, &allocation);
60
state = gtk_widget_get_state_flags (widget);
61
width = gtk_widget_get_allocated_width (widget);
62
height = gtk_widget_get_allocated_height (widget);
64
context = gtk_widget_get_style_context (widget);
65
gtk_style_context_get_padding (context, state, &padding);
67
gtk_style_context_save (context);
68
gtk_style_context_set_state (context, state);
59
71
if (separator->priv->orientation == GTK_ORIENTATION_HORIZONTAL) {
60
gtk_paint_vline (style, window,
61
gtk_widget_get_state (widget),
62
area, widget, "separator",
64
allocation.height - style->xthickness,
65
(allocation.width - style->xthickness) / 2);
74
x= (width - padding.left - padding.right) / 2 + padding.left;
75
x = MIN (x, width - padding.right);
77
gtk_render_line (context, cr,
79
x, height - padding.bottom);
67
gtk_paint_hline (style, window,
68
gtk_widget_get_state (widget),
69
area, widget, "separator",
71
allocation.width - style->ythickness,
72
(allocation.height - style->ythickness) / 2);
77
panel_separator_expose_event (GtkWidget *widget,
78
GdkEventExpose *event)
80
if (gtk_widget_is_drawable (widget)) {
81
GTK_WIDGET_CLASS (panel_separator_parent_class)->expose_event (widget, event);
83
panel_separator_paint (widget, &event->area);
83
y = (height - padding.top - padding.bottom) / 2 + padding.top;
84
y = MIN (y, height - padding.bottom);
86
gtk_render_line (context, cr,
88
width - padding.right, y);
92
gtk_style_context_restore (context);
90
panel_separator_size_request (GtkWidget *widget,
91
GtkRequisition *requisition)
93
PanelSeparator *separator;
96
separator = PANEL_SEPARATOR (widget);
98
size = panel_toplevel_get_size (separator->priv->panel->toplevel);
100
if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL) {
101
requisition->width = size;
102
requisition->height = SEPARATOR_SIZE;
104
requisition->width = SEPARATOR_SIZE;
105
requisition->height = size;
98
panel_separator_get_preferred_width (GtkWidget *widget,
102
PanelSeparator *separator;
105
separator = PANEL_SEPARATOR (widget);
107
size = panel_toplevel_get_size (separator->priv->panel->toplevel);
109
if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
110
*minimal_width = *natural_width = size;
112
*minimal_width = *natural_width = SEPARATOR_SIZE;
116
panel_separator_get_preferred_height (GtkWidget *widget,
117
gint *minimal_height,
118
gint *natural_height)
120
PanelSeparator *separator;
123
separator = PANEL_SEPARATOR (widget);
125
size = panel_toplevel_get_size (separator->priv->panel->toplevel);
127
if (separator->priv->orientation == GTK_ORIENTATION_VERTICAL)
128
*minimal_height = *natural_height = SEPARATOR_SIZE;
130
*minimal_height = *natural_height = size;