1
/* -*- Separator: C; tab-width: 8; indent-tabs-separator: nil; c-basic-offset: 8 -*-
3
* Copyright (C) 2012 Red Hat, Inc.
5
* Licensed under the GNU General Public License Version 2
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
* Written by Matthias Clasen
27
#include <glib/gi18n.h>
30
#include "panel-cell-renderer-separator.h"
38
G_DEFINE_TYPE (PanelCellRendererSeparator, panel_cell_renderer_separator, GTK_TYPE_CELL_RENDERER)
41
panel_cell_renderer_separator_get_property (GObject *object,
46
PanelCellRendererSeparator *renderer = PANEL_CELL_RENDERER_SEPARATOR (object);
50
g_value_set_boolean (value, renderer->draw);
53
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
59
panel_cell_renderer_separator_set_property (GObject *object,
64
PanelCellRendererSeparator *renderer = PANEL_CELL_RENDERER_SEPARATOR (object);
68
renderer->draw = g_value_get_boolean (value);
71
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
77
render (GtkCellRenderer *cell,
80
const GdkRectangle *background_area,
81
const GdkRectangle *cell_area,
82
GtkCellRendererState flags)
84
PanelCellRendererSeparator *renderer = PANEL_CELL_RENDERER_SEPARATOR (cell);
85
GtkStyleContext *context;
86
gint x, y, w, h, xpad, ypad;
91
context = gtk_widget_get_style_context (widget);
93
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
95
x = cell_area->x + xpad;
96
y = cell_area->y + ypad;
97
w = cell_area->width - xpad * 2;
98
h = cell_area->height - ypad * 2;
100
gtk_render_line (context, cr, x + w / 2, y, x + w / 2, y + h - 1);
104
panel_cell_renderer_separator_class_init (PanelCellRendererSeparatorClass *class)
106
GObjectClass *object_class = G_OBJECT_CLASS (class);
107
GtkCellRendererClass *cell_renderer_class = GTK_CELL_RENDERER_CLASS (class);
109
object_class->get_property = panel_cell_renderer_separator_get_property;
110
object_class->set_property = panel_cell_renderer_separator_set_property;
112
cell_renderer_class->render = render;
114
g_object_class_install_property (object_class, PROP_DRAW,
115
g_param_spec_boolean ("draw", "draw", "draw",
121
panel_cell_renderer_separator_init (PanelCellRendererSeparator *renderer)
123
renderer->draw = TRUE;
127
panel_cell_renderer_separator_new (void)
129
return g_object_new (PANEL_TYPE_CELL_RENDERER_SEPARATOR, NULL);