1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ |
---|
2 | /* e-gray-bar.c |
---|
3 | * |
---|
4 | * Copyright (C) 2001 Ximian, Inc. |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or |
---|
7 | * modify it under the terms of version 2 of the GNU General Public |
---|
8 | * License as published by the Free Software Foundation. |
---|
9 | * |
---|
10 | * This program is distributed in the hope that it will be useful, |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | * General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU General Public |
---|
16 | * License along with this program; if not, write to the |
---|
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
18 | * Boston, MA 02111-1307, USA. |
---|
19 | * |
---|
20 | * Author: Ettore Perazzoli <ettore@ximian.com> |
---|
21 | */ |
---|
22 | |
---|
23 | #ifdef HAVE_CONFIG_H |
---|
24 | #include <config.h> |
---|
25 | #endif |
---|
26 | |
---|
27 | #include "e-gray-bar.h" |
---|
28 | |
---|
29 | #include <gtk/gtkrc.h> |
---|
30 | #include <gtk/gtktypeutils.h> |
---|
31 | #include <gtk/gtkwidget.h> |
---|
32 | |
---|
33 | #include <gal/util/e-util.h> |
---|
34 | |
---|
35 | |
---|
36 | #define PARENT_TYPE gtk_event_box_get_type () |
---|
37 | static GtkEventBoxClass *parent_class = NULL; |
---|
38 | |
---|
39 | |
---|
40 | static void |
---|
41 | endarken_style (GtkWidget *widget) |
---|
42 | { |
---|
43 | GtkRcStyle *rc_style = gtk_rc_style_new(); |
---|
44 | |
---|
45 | rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_BG; |
---|
46 | rc_style->bg[GTK_STATE_NORMAL].red = 0x8000; |
---|
47 | rc_style->bg[GTK_STATE_NORMAL].green = 0x8000; |
---|
48 | rc_style->bg[GTK_STATE_NORMAL].blue = 0x8000; |
---|
49 | |
---|
50 | rc_style->color_flags[GTK_STATE_INSENSITIVE] |= GTK_RC_BG; |
---|
51 | rc_style->bg[GTK_STATE_INSENSITIVE].red = 0x8000; |
---|
52 | rc_style->bg[GTK_STATE_INSENSITIVE].green = 0x8000; |
---|
53 | rc_style->bg[GTK_STATE_INSENSITIVE].blue = 0x8000; |
---|
54 | |
---|
55 | gtk_widget_modify_style (widget, rc_style); |
---|
56 | gtk_rc_style_unref (rc_style); |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | static void |
---|
61 | impl_style_set (GtkWidget *widget, |
---|
62 | GtkStyle *previous_style) |
---|
63 | { |
---|
64 | static int in_style_set = 0; |
---|
65 | |
---|
66 | if (in_style_set > 0) |
---|
67 | return; |
---|
68 | |
---|
69 | in_style_set ++; |
---|
70 | |
---|
71 | endarken_style (widget); |
---|
72 | |
---|
73 | in_style_set --; |
---|
74 | |
---|
75 | (* GTK_WIDGET_CLASS (parent_class)->style_set) (widget, previous_style); |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | static void |
---|
80 | class_init (GtkObjectClass *object_class) |
---|
81 | { |
---|
82 | GtkWidgetClass *widget_class; |
---|
83 | |
---|
84 | parent_class = gtk_type_class (PARENT_TYPE); |
---|
85 | |
---|
86 | widget_class = GTK_WIDGET_CLASS (object_class); |
---|
87 | widget_class->style_set = impl_style_set; |
---|
88 | } |
---|
89 | |
---|
90 | static void |
---|
91 | init (EGrayBar *gray_bar) |
---|
92 | { |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | GtkWidget * |
---|
97 | e_gray_bar_new (void) |
---|
98 | { |
---|
99 | GtkWidget *new; |
---|
100 | |
---|
101 | new = gtk_type_new (e_gray_bar_get_type ()); |
---|
102 | |
---|
103 | return new; |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | E_MAKE_TYPE (e_gray_bar, "EGrayBar", EGrayBar, class_init, init, PARENT_TYPE) |
---|