1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
* gdl-dock-item-button-image.c
5
* Author: Joel Holdsworth <joel@airwebreathe.org.uk>
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Library General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library 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 GNU
15
* Library General Public License for more details.
17
* You should have received a copy of the GNU Library General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
23
#include "gdl-dock-item-button-image.h"
26
#include "gdl-tools.h"
30
GDL_CLASS_BOILERPLATE (GdlDockItemButtonImage,
31
gdl_dock_item_button_image,
32
GtkWidget, GTK_TYPE_WIDGET);
35
gdl_dock_item_button_image_expose (GtkWidget *widget,
36
GdkEventExpose *event)
38
GdlDockItemButtonImage *button_image;
42
g_return_val_if_fail (widget != NULL, 0);
43
button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget);
45
cairo_t *cr = gdk_cairo_create (event->window);
46
cairo_translate (cr, event->area.x, event->area.y);
49
cairo_set_line_width(cr, 1.0);
51
style = gtk_widget_get_style (widget);
52
g_return_val_if_fail (style != NULL, 0);
53
color = &style->fg[GTK_STATE_NORMAL];
54
cairo_set_source_rgba(cr, color->red / 65535.0,
55
color->green / 65535.0, color->blue / 65535.0, 0.55);
57
/* Draw the icon border */
58
cairo_move_to (cr, 10.5, 2.5);
59
cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0);
60
cairo_line_to (cr, 12.5, 10.5);
61
cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI);
62
cairo_line_to (cr, 4.5, 12.5);
63
cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI);
64
cairo_line_to (cr, 2.5, 4.5);
65
cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI);
66
cairo_close_path (cr);
73
switch(button_image->image_type) {
74
case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE:
75
cairo_move_to (cr, 4.0, 5.5);
76
cairo_line_to (cr, 4.0, 5.5);
77
cairo_line_to (cr, 6.0, 7.5);
78
cairo_line_to (cr, 4.0, 9.5);
79
cairo_line_to (cr, 5.5, 11.0);
80
cairo_line_to (cr, 7.5, 9.0);
81
cairo_line_to (cr, 9.5, 11.0);
82
cairo_line_to (cr, 11.0, 9.5);
83
cairo_line_to (cr, 9.0, 7.5);
84
cairo_line_to (cr, 11.0, 5.5);
85
cairo_line_to (cr, 9.5, 4.0);
86
cairo_line_to (cr, 7.5, 6.0);
87
cairo_line_to (cr, 5.5, 4.0);
88
cairo_close_path (cr);
91
case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY:
92
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
93
cairo_move_to (cr, 4.5, 7.5);
94
cairo_line_to (cr, 10.0, 4.75);
95
cairo_line_to (cr, 10.0, 10.25);
96
cairo_close_path (cr);
98
cairo_move_to (cr, 10.5, 7.5);
99
cairo_line_to (cr, 5, 4.75);
100
cairo_line_to (cr, 5, 10.25);
101
cairo_close_path (cr);
118
gdl_dock_item_button_image_instance_init (
119
GdlDockItemButtonImage *button_image)
121
GTK_WIDGET_SET_FLAGS (button_image, GTK_NO_WINDOW);
125
gdl_dock_item_button_image_size_request (GtkWidget *widget,
126
GtkRequisition *requisition)
128
g_return_if_fail (GDL_IS_DOCK_ITEM_BUTTON_IMAGE (widget));
129
g_return_if_fail (requisition != NULL);
131
requisition->width = ICON_SIZE;
132
requisition->height = ICON_SIZE;
136
gdl_dock_item_button_image_class_init (
137
GdlDockItemButtonImageClass *klass)
139
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
140
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
141
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
143
parent_class = g_type_class_peek_parent (klass);
145
widget_class->expose_event =
146
gdl_dock_item_button_image_expose;
147
widget_class->size_request =
148
gdl_dock_item_button_image_size_request;
151
/* ----- Public interface ----- */
154
* gdl_dock_item_button_image_new:
155
* @param image_type: Specifies what type of image the widget should
158
* Creates a new GDL dock button image object.
159
* Returns: The newly created dock item button image widget.
162
gdl_dock_item_button_image_new (GdlDockItemButtonImageType image_type)
164
GdlDockItemButtonImage *button_image = g_object_new (
165
GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, NULL);
166
button_image->image_type = image_type;
168
return GTK_WIDGET (button_image);