Mercurial > audlegacy
annotate src/audacious/ui_skinned_button.c @ 2910:6cd68e70e86d trunk
fix previous commit
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Thu, 28 Jun 2007 17:05:29 +0200 |
parents | 4829dd0c8975 |
children | 4e71092ab29b |
rev | line source |
---|---|
2822 | 1 /* |
2 * Audacious - a cross-platform multimedia player | |
3 * Copyright (c) 2007 Audacious development team. | |
4 * | |
5 * This program is free software; you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation; either version 2 of the License, or | |
8 * (at your option) any later version. | |
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 | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
18 */ | |
19 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
20 #include "widgets/widgetcore.h" |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
21 #include "ui_skinned_button.h" |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
22 #include "util.h" |
2822 | 23 |
24 #include <gtk/gtkmain.h> | |
25 #include <gtk/gtkmarshal.h> | |
26 #include <gtk/gtkimage.h> | |
27 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
28 #define UI_SKINNED_BUTTON_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UI_TYPE_SKINNED_BUTTON, UiSkinnedButtonPrivate)) |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
29 typedef struct _UiSkinnedButtonPrivate UiSkinnedButtonPrivate; |
2822 | 30 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
31 struct _UiSkinnedButtonPrivate { |
2822 | 32 //Skinned part |
33 GtkWidget *image; | |
34 GdkGC *gc; | |
35 gint w; | |
36 gint h; | |
37 SkinPixmapId skin_index1; | |
38 SkinPixmapId skin_index2; | |
39 GtkWidget *fixed; | |
2827 | 40 gboolean double_size; |
2822 | 41 }; |
42 | |
43 | |
44 static GtkBinClass *parent_class = NULL; | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
45 static void ui_skinned_button_class_init(UiSkinnedButtonClass *klass); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
46 static void ui_skinned_button_init(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
47 static GObject* ui_skinned_button_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
48 static void ui_skinned_button_destroy(GtkObject *object); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
49 static void ui_skinned_button_realize(GtkWidget *widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
50 static void ui_skinned_button_unrealize(GtkWidget *widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
51 static void ui_skinned_button_map(GtkWidget *widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
52 static void ui_skinned_button_unmap(GtkWidget *widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
53 static gint ui_skinned_button_expose(GtkWidget *widget,GdkEventExpose *event); |
2822 | 54 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
55 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
56 static void ui_skinned_button_update_state(UiSkinnedButton *button); |
2822 | 57 |
58 static guint button_signals[LAST_SIGNAL] = { 0 }; | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
59 static gint ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
60 static gint ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
61 static void button_pressed(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
62 static void button_released(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
63 static void ui_skinned_button_pressed(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
64 static void ui_skinned_button_released(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
65 static void ui_skinned_button_clicked(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
66 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed); |
2834 | 67 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
68 static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
69 static void ui_skinned_button_toggle_doublesize(UiSkinnedButton *button); |
2822 | 70 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
71 static gint ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
72 static gint ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
73 static void ui_skinned_button_paint(UiSkinnedButton *button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
74 static void ui_skinned_button_redraw(UiSkinnedButton *button); |
2822 | 75 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
76 GType ui_skinned_button_get_type (void) { |
2822 | 77 static GType button_type = 0; |
78 | |
79 if (!button_type) { | |
80 static const GTypeInfo button_info = { | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
81 sizeof (UiSkinnedButtonClass), |
2822 | 82 NULL, /* base_init */ |
83 NULL, /* base_finalize */ | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
84 (GClassInitFunc) ui_skinned_button_class_init, |
2822 | 85 NULL, /* class_finalize */ |
86 NULL, /* class_data */ | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
87 sizeof (UiSkinnedButton), |
2822 | 88 16, /* n_preallocs */ |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
89 (GInstanceInitFunc) ui_skinned_button_init, |
2822 | 90 }; |
91 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
92 button_type = g_type_register_static (GTK_TYPE_BIN, "UiSkinnedButton", &button_info, 0); |
2822 | 93 } |
94 return button_type; | |
95 } | |
96 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
97 static void ui_skinned_button_class_init (UiSkinnedButtonClass *klass) { |
2822 | 98 GObjectClass *gobject_class; |
99 GtkObjectClass *object_class; | |
100 GtkWidgetClass *widget_class; | |
101 GtkContainerClass *container_class; | |
102 | |
103 gobject_class = G_OBJECT_CLASS(klass); | |
104 object_class = (GtkObjectClass*)klass; | |
105 widget_class = (GtkWidgetClass*)klass; | |
106 container_class = (GtkContainerClass*)klass; | |
107 | |
108 parent_class = g_type_class_peek_parent(klass); | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
109 gobject_class->constructor = ui_skinned_button_constructor; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
110 object_class->destroy = ui_skinned_button_destroy; |
2822 | 111 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
112 widget_class->realize = ui_skinned_button_realize; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
113 widget_class->unrealize = ui_skinned_button_unrealize; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
114 widget_class->map = ui_skinned_button_map; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
115 widget_class->unmap = ui_skinned_button_unmap; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
116 widget_class->size_allocate = ui_skinned_button_size_allocate; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
117 widget_class->expose_event = ui_skinned_button_expose; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
118 widget_class->button_press_event = ui_skinned_button_button_press; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
119 widget_class->button_release_event = ui_skinned_button_button_release; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
120 widget_class->enter_notify_event = ui_skinned_button_enter_notify; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
121 widget_class->leave_notify_event = ui_skinned_button_leave_notify; |
2822 | 122 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
123 container_class->add = ui_skinned_button_add; |
2822 | 124 |
125 klass->pressed = button_pressed; | |
126 klass->released = button_released; | |
127 klass->clicked = NULL; | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
128 klass->doubled = ui_skinned_button_toggle_doublesize; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
129 klass->redraw = ui_skinned_button_redraw; |
2822 | 130 |
131 button_signals[PRESSED] = | |
132 g_signal_new ("pressed", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
133 G_STRUCT_OFFSET (UiSkinnedButtonClass, pressed), NULL, NULL, |
2822 | 134 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
135 | |
136 button_signals[RELEASED] = | |
137 g_signal_new ("released", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST, | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
138 G_STRUCT_OFFSET (UiSkinnedButtonClass, released), NULL, NULL, |
2822 | 139 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
140 | |
141 button_signals[CLICKED] = | |
142 g_signal_new ("clicked", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
143 G_STRUCT_OFFSET (UiSkinnedButtonClass, clicked), NULL, NULL, |
2822 | 144 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
145 | |
146 button_signals[DOUBLED] = | |
2827 | 147 g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
148 G_STRUCT_OFFSET (UiSkinnedButtonClass, doubled), NULL, NULL, |
2822 | 149 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
150 | |
2829
4eda78b785ed
[svn] - draw_main_window redraws custom gtk widgets
desowin
parents:
2828
diff
changeset
|
151 button_signals[REDRAW] = |
4eda78b785ed
[svn] - draw_main_window redraws custom gtk widgets
desowin
parents:
2828
diff
changeset
|
152 g_signal_new ("redraw", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
153 G_STRUCT_OFFSET (UiSkinnedButtonClass, redraw), NULL, NULL, |
2829
4eda78b785ed
[svn] - draw_main_window redraws custom gtk widgets
desowin
parents:
2828
diff
changeset
|
154 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); |
4eda78b785ed
[svn] - draw_main_window redraws custom gtk widgets
desowin
parents:
2828
diff
changeset
|
155 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
156 g_type_class_add_private (gobject_class, sizeof (UiSkinnedButtonPrivate)); |
2822 | 157 } |
158 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
159 static void ui_skinned_button_init (UiSkinnedButton *button) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
160 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
2822 | 161 priv->image = gtk_image_new(); |
2833 | 162 button->redraw = TRUE; |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
163 button->inside = FALSE; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
164 button->type = TYPE_NOT_SET; |
2833 | 165 |
2822 | 166 g_object_set (priv->image, "visible", TRUE, NULL); |
167 gtk_container_add(GTK_CONTAINER(GTK_WIDGET(button)), priv->image); | |
168 | |
169 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS); | |
170 GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW); | |
171 } | |
172 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
173 static void ui_skinned_button_destroy (GtkObject *object) { |
2822 | 174 (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); |
175 } | |
176 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
177 static GObject* ui_skinned_button_constructor(GType type, guint n_construct_properties, GObjectConstructParam *construct_params) { |
2822 | 178 GObject *object = (*G_OBJECT_CLASS (parent_class)->constructor)(type, n_construct_properties, construct_params); |
179 | |
180 return object; | |
181 } | |
182 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
183 static void ui_skinned_button_realize (GtkWidget *widget) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
184 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); |
2822 | 185 GdkWindowAttr attrib; |
186 | |
187 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); | |
188 | |
189 attrib.window_type = GDK_WINDOW_CHILD; | |
190 attrib.x = widget->allocation.x; | |
191 attrib.y = widget->allocation.y; | |
192 attrib.width = widget->allocation.width; | |
193 attrib.height = widget->allocation.height; | |
194 attrib.wclass = GDK_INPUT_ONLY; | |
195 attrib.event_mask = gtk_widget_get_events (widget); | |
196 attrib.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); | |
197 | |
198 widget->window = gtk_widget_get_parent_window(widget); | |
199 g_object_ref(widget->window); | |
200 | |
201 button->event_window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrib, GDK_WA_X | GDK_WA_Y); | |
202 gdk_window_set_user_data (button->event_window, button); | |
203 } | |
204 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
205 static void ui_skinned_button_unrealize(GtkWidget *widget) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
206 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); |
2822 | 207 |
208 if (button->event_window) { | |
209 gdk_window_set_user_data (button->event_window, NULL); | |
210 gdk_window_destroy (button->event_window); | |
211 button->event_window = NULL; | |
212 } | |
213 | |
214 GTK_WIDGET_CLASS (parent_class)->unrealize (widget); | |
215 } | |
216 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
217 static void ui_skinned_button_map(GtkWidget *widget) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
218 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
219 g_return_if_fail (UI_IS_SKINNED_BUTTON (widget)); |
2822 | 220 GTK_WIDGET_CLASS (parent_class)->map(widget); |
221 gdk_window_show (button->event_window); | |
222 } | |
223 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
224 static void ui_skinned_button_unmap (GtkWidget *widget) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
225 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
226 g_return_if_fail (UI_IS_SKINNED_BUTTON(widget)); |
2822 | 227 |
228 if (button->event_window) | |
229 gdk_window_hide (button->event_window); | |
230 | |
231 GTK_WIDGET_CLASS (parent_class)->unmap (widget); | |
232 } | |
233 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
234 static gboolean ui_skinned_button_expose(GtkWidget *widget, GdkEventExpose *event) { |
2822 | 235 if (GTK_WIDGET_DRAWABLE (widget)) |
236 (*GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); | |
237 | |
238 return FALSE; | |
239 } | |
240 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
241 GtkWidget* ui_skinned_button_new () { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
242 return g_object_new (UI_TYPE_SKINNED_BUTTON, NULL); |
2822 | 243 } |
244 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
245 void ui_skinned_push_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, SkinPixmapId si) { |
2822 | 246 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
247 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
248 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton); |
2822 | 249 priv->gc = gc; |
250 priv->w = w; | |
251 priv->h = h; | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
252 sbutton->x = x; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
253 sbutton->y = y; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
254 sbutton->nx = nx; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
255 sbutton->ny = ny; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
256 sbutton->px = px; |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
257 sbutton->py = py; |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
258 sbutton->type = TYPE_PUSH; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
259 priv->skin_index1 = si; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
260 priv->skin_index2 = si; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
261 priv->fixed = fixed; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
262 priv->double_size = FALSE; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
263 |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
264 gtk_widget_set_size_request(button, priv->w, priv->h); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
265 gtk_fixed_put(GTK_FIXED(priv->fixed),GTK_WIDGET(button), sbutton->x, sbutton->y); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
266 } |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
267 |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
268 void ui_skinned_toggle_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h, gint nx, gint ny, gint px, gint py, gint pnx, gint pny, gint ppx, gint ppy, SkinPixmapId si) { |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
269 |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
270 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
271 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
272 priv->gc = gc; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
273 priv->w = w; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
274 priv->h = h; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
275 sbutton->x = x; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
276 sbutton->y = y; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
277 sbutton->nx = nx; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
278 sbutton->ny = ny; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
279 sbutton->px = px; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
280 sbutton->py = py; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
281 sbutton->pnx = pnx; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
282 sbutton->pny = pny; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
283 sbutton->ppx = ppx; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
284 sbutton->ppy = ppy; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
285 sbutton->type = TYPE_TOGGLE; |
2822 | 286 priv->skin_index1 = si; |
287 priv->skin_index2 = si; | |
288 priv->fixed = fixed; | |
2827 | 289 priv->double_size = FALSE; |
2822 | 290 |
291 gtk_widget_set_size_request(button, priv->w, priv->h); | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
292 gtk_fixed_put(GTK_FIXED(priv->fixed),GTK_WIDGET(button), sbutton->x, sbutton->y); |
2822 | 293 } |
294 | |
2844
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
295 void ui_skinned_small_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h) { |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
296 |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
297 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button); |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
298 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton); |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
299 priv->gc = gc; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
300 priv->w = w; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
301 priv->h = h; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
302 sbutton->x = x; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
303 sbutton->y = y; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
304 sbutton->type = TYPE_SMALL; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
305 priv->fixed = fixed; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
306 priv->double_size = FALSE; |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
307 |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
308 gtk_widget_set_size_request(button, priv->w, priv->h); |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
309 gtk_fixed_put(GTK_FIXED(priv->fixed),GTK_WIDGET(button), sbutton->x, sbutton->y); |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
310 } |
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
311 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
312 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
313 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); |
2910 | 314 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
2822 | 315 GtkAllocation child_alloc; |
316 | |
317 widget->allocation = *allocation; | |
318 if (GTK_BIN (button)->child) { //image should fill whole widget | |
319 child_alloc.x = widget->allocation.x; | |
320 child_alloc.y = widget->allocation.y; | |
321 child_alloc.width = MAX (1, widget->allocation.width); | |
322 child_alloc.height = MAX (1, widget->allocation.height); | |
323 | |
324 gtk_widget_size_allocate (GTK_BIN (button)->child, &child_alloc); | |
325 } | |
2828 | 326 |
327 if (GDK_IS_WINDOW(button->event_window)) | |
328 gdk_window_move_resize (button->event_window, widget->allocation.x, widget->allocation.y, | |
329 widget->allocation.width, widget->allocation.height); | |
2910 | 330 |
331 button->x = widget->allocation.x/(priv->double_size ? 2 : 1); | |
332 button->y = widget->allocation.y/(priv->double_size ? 2 : 1); | |
2822 | 333 } |
334 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
335 static void button_pressed(UiSkinnedButton *button) { |
2822 | 336 button->button_down = TRUE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
337 ui_skinned_button_update_state(button); |
2822 | 338 } |
339 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
340 static void button_released(UiSkinnedButton *button) { |
2822 | 341 button->button_down = FALSE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
342 if(button->hover) ui_skinned_button_clicked(button); |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
343 ui_skinned_button_update_state(button); |
2822 | 344 } |
345 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
346 static void ui_skinned_button_update_state(UiSkinnedButton *button) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
347 ui_skinned_button_set_pressed(button, button->button_down); |
2822 | 348 } |
349 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
350 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed) { |
2822 | 351 if (pressed != button->pressed) { |
352 button->pressed = pressed; | |
2833 | 353 button->redraw = TRUE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
354 ui_skinned_button_paint(button); |
2822 | 355 } |
356 } | |
357 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
358 static gboolean ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
359 UiSkinnedButton *button; |
2822 | 360 |
361 if (event->type == GDK_BUTTON_PRESS) { | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
362 button = UI_SKINNED_BUTTON(widget); |
2822 | 363 |
364 if (event->button == 1) | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
365 ui_skinned_button_pressed (button); |
2822 | 366 } |
367 | |
368 return TRUE; | |
369 } | |
370 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
371 static gboolean ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
372 UiSkinnedButton *button; |
2822 | 373 if (event->button == 1) { |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
374 button = UI_SKINNED_BUTTON(widget); |
2833 | 375 button->redraw = TRUE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
376 ui_skinned_button_released(button); |
2822 | 377 } |
378 | |
379 return TRUE; | |
380 } | |
381 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
382 static void ui_skinned_button_pressed(UiSkinnedButton *button) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
383 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
2822 | 384 g_signal_emit(button, button_signals[PRESSED], 0); |
385 } | |
386 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
387 static void ui_skinned_button_released(UiSkinnedButton *button) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
388 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
2822 | 389 g_signal_emit(button, button_signals[RELEASED], 0); |
390 } | |
391 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
392 static void ui_skinned_button_clicked(UiSkinnedButton *button) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
393 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
394 button->inside = !button->inside; |
2822 | 395 g_signal_emit(button, button_signals[CLICKED], 0); |
396 } | |
397 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
398 static gboolean ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
399 UiSkinnedButton *button; |
2822 | 400 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
401 button = UI_SKINNED_BUTTON(widget); |
2822 | 402 button->hover = TRUE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
403 if(button->button_down) ui_skinned_button_set_pressed(button, TRUE); |
2822 | 404 |
405 return FALSE; | |
406 } | |
407 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
408 static gboolean ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event) { |
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
409 UiSkinnedButton *button; |
2822 | 410 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
411 button = UI_SKINNED_BUTTON (widget); |
2822 | 412 button->hover = FALSE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
413 if(button->button_down) ui_skinned_button_set_pressed(button, FALSE); |
2822 | 414 |
415 return FALSE; | |
416 } | |
417 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
418 static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget) { |
2822 | 419 GTK_CONTAINER_CLASS (parent_class)->add(container, widget); |
420 } | |
421 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
422 static void ui_skinned_button_toggle_doublesize(UiSkinnedButton *button) { |
2827 | 423 GtkWidget *widget = GTK_WIDGET (button); |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
424 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
2827 | 425 priv->double_size = !priv->double_size; |
426 | |
427 gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size)); | |
428 gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size)); | |
429 | |
2833 | 430 button->redraw = TRUE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
431 ui_skinned_button_paint(button); |
2822 | 432 } |
433 | |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
434 static void ui_skinned_button_paint(UiSkinnedButton *button) { |
2822 | 435 GtkWidget *widget = GTK_WIDGET (button); |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
436 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
2822 | 437 |
2844
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
438 //TYPE_SMALL doesn't have its own face |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
439 if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET) |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
440 return; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
441 |
2833 | 442 if (button->redraw == TRUE) { |
443 button->redraw = FALSE; | |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
444 |
2833 | 445 GdkPixmap *obj; |
446 obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth); | |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
447 switch (button->type) { |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
448 case TYPE_PUSH: |
2854 | 449 skin_draw_pixmap(bmp_active_skin, obj, priv->gc, |
450 button->pressed ? priv->skin_index2 : priv->skin_index1, | |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
451 button->pressed ? button->px : button->nx, |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
452 button->pressed ? button->py : button->ny, |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
453 0, 0, priv->w, priv->h); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
454 break; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
455 case TYPE_TOGGLE: |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
456 if (button->inside) |
2854 | 457 skin_draw_pixmap(bmp_active_skin, obj, priv->gc, |
458 button->pressed ? priv->skin_index2 : priv->skin_index1, | |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
459 button->pressed ? button->ppx : button->pnx, |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
460 button->pressed ? button->ppy : button->pny, |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
461 0, 0, priv->w, priv->h); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
462 else |
2854 | 463 skin_draw_pixmap(bmp_active_skin, obj, priv->gc, |
464 button->pressed ? priv->skin_index2 : priv->skin_index1, | |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
465 button->pressed ? button->px : button->nx, |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
466 button->pressed ? button->py : button->ny, |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
467 0, 0, priv->w, priv->h); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
468 break; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
469 default: |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
470 break; |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
471 } |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
472 |
2833 | 473 if(priv->double_size) { |
474 GdkImage *img, *img2x; | |
475 img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h); | |
476 img2x = create_dblsize_image(img); | |
477 gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL); | |
478 g_object_unref(img2x); | |
479 g_object_unref(img); | |
480 } else | |
481 gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL); | |
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
482 |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
483 g_object_unref(obj); |
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
484 gtk_widget_queue_resize(widget); |
2833 | 485 } |
2822 | 486 } |
2833 | 487 |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
488 static void ui_skinned_button_redraw(UiSkinnedButton *button) { |
2833 | 489 button->redraw = TRUE; |
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
490 ui_skinned_button_paint(button); |
2833 | 491 } |
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
492 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
493 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
494 void ui_skinned_set_push_button_data(GtkWidget *button, gint nx, gint ny, gint px, gint py) { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
495 UiSkinnedButton *b = UI_SKINNED_BUTTON(button); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
496 if (nx > -1) b->nx = nx; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
497 if (ny > -1) b->ny = ny; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
498 if (px > -1) b->px = px; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
499 if (py > -1) b->py = py; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
500 } |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
501 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
502 void ui_skinned_button_set_skin_index(GtkWidget *button, SkinPixmapId si) { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
503 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
504 priv->skin_index1 = priv->skin_index2 = si; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
505 } |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
506 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
507 void ui_skinned_button_set_skin_index1(GtkWidget *button, SkinPixmapId si) { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
508 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
509 priv->skin_index1 = si; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
510 } |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
511 |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
512 void ui_skinned_button_set_skin_index2(GtkWidget *button, SkinPixmapId si) { |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
513 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
514 priv->skin_index2 = si; |
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
515 } |
2901
5ed0674fabd6
replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2854
diff
changeset
|
516 |
5ed0674fabd6
replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2854
diff
changeset
|
517 void ui_skinned_button_move_relative(GtkWidget *button, gint x, gint y) { |
5ed0674fabd6
replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2854
diff
changeset
|
518 UiSkinnedButton *b = UI_SKINNED_BUTTON(button); |
5ed0674fabd6
replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2854
diff
changeset
|
519 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
5ed0674fabd6
replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2854
diff
changeset
|
520 gtk_fixed_move(GTK_FIXED(priv->fixed), button, b->x+x, b->y+y); |
5ed0674fabd6
replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
2854
diff
changeset
|
521 } |