Mercurial > audlegacy
annotate src/audacious/ui_skinned_button.c @ 2853:bec320cfcc12 trunk
use UiSkinnedButton instead of PButton in equalizerwin
| author | Tomasz Mon <desowin@gmail.com> |
|---|---|
| date | Fri, 22 Jun 2007 17:23:58 +0200 |
| parents | 22da7cd0eca0 |
| children | 9f37fd52e7d0 |
| 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); |
| 2822 | 314 GtkAllocation child_alloc; |
| 315 | |
| 316 widget->allocation = *allocation; | |
| 317 if (GTK_BIN (button)->child) { //image should fill whole widget | |
| 318 child_alloc.x = widget->allocation.x; | |
| 319 child_alloc.y = widget->allocation.y; | |
| 320 child_alloc.width = MAX (1, widget->allocation.width); | |
| 321 child_alloc.height = MAX (1, widget->allocation.height); | |
| 322 | |
| 323 gtk_widget_size_allocate (GTK_BIN (button)->child, &child_alloc); | |
| 324 } | |
| 2828 | 325 |
| 326 if (GDK_IS_WINDOW(button->event_window)) | |
| 327 gdk_window_move_resize (button->event_window, widget->allocation.x, widget->allocation.y, | |
| 328 widget->allocation.width, widget->allocation.height); | |
| 2822 | 329 } |
| 330 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
331 static void button_pressed(UiSkinnedButton *button) { |
| 2822 | 332 button->button_down = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
333 ui_skinned_button_update_state(button); |
| 2822 | 334 } |
| 335 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
336 static void button_released(UiSkinnedButton *button) { |
| 2822 | 337 button->button_down = FALSE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
338 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
|
339 ui_skinned_button_update_state(button); |
| 2822 | 340 } |
| 341 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
342 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
|
343 ui_skinned_button_set_pressed(button, button->button_down); |
| 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_set_pressed (UiSkinnedButton *button, gboolean pressed) { |
| 2822 | 347 if (pressed != button->pressed) { |
| 348 button->pressed = pressed; | |
| 2833 | 349 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
350 ui_skinned_button_paint(button); |
| 2822 | 351 } |
| 352 } | |
| 353 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
354 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
|
355 UiSkinnedButton *button; |
| 2822 | 356 |
| 357 if (event->type == GDK_BUTTON_PRESS) { | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
358 button = UI_SKINNED_BUTTON(widget); |
| 2822 | 359 |
| 360 if (event->button == 1) | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
361 ui_skinned_button_pressed (button); |
| 2822 | 362 } |
| 363 | |
| 364 return TRUE; | |
| 365 } | |
| 366 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
367 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
|
368 UiSkinnedButton *button; |
| 2822 | 369 if (event->button == 1) { |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
370 button = UI_SKINNED_BUTTON(widget); |
| 2833 | 371 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
372 ui_skinned_button_released(button); |
| 2822 | 373 } |
| 374 | |
| 375 return TRUE; | |
| 376 } | |
| 377 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
378 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
|
379 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
| 2822 | 380 g_signal_emit(button, button_signals[PRESSED], 0); |
| 381 } | |
| 382 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
383 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
|
384 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
| 2822 | 385 g_signal_emit(button, button_signals[RELEASED], 0); |
| 386 } | |
| 387 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
388 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
|
389 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
|
390 button->inside = !button->inside; |
| 2822 | 391 g_signal_emit(button, button_signals[CLICKED], 0); |
| 392 } | |
| 393 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
394 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
|
395 UiSkinnedButton *button; |
| 2822 | 396 |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
397 button = UI_SKINNED_BUTTON(widget); |
| 2822 | 398 button->hover = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
399 if(button->button_down) ui_skinned_button_set_pressed(button, TRUE); |
| 2822 | 400 |
| 401 return FALSE; | |
| 402 } | |
| 403 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
404 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
|
405 UiSkinnedButton *button; |
| 2822 | 406 |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
407 button = UI_SKINNED_BUTTON (widget); |
| 2822 | 408 button->hover = FALSE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
409 if(button->button_down) ui_skinned_button_set_pressed(button, FALSE); |
| 2822 | 410 |
| 411 return FALSE; | |
| 412 } | |
| 413 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
414 static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget) { |
| 2822 | 415 GTK_CONTAINER_CLASS (parent_class)->add(container, widget); |
| 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_toggle_doublesize(UiSkinnedButton *button) { |
| 2827 | 419 GtkWidget *widget = GTK_WIDGET (button); |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
420 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
| 2827 | 421 priv->double_size = !priv->double_size; |
| 422 | |
| 423 gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size)); | |
| 424 gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size)); | |
| 425 | |
| 2833 | 426 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
427 ui_skinned_button_paint(button); |
| 2822 | 428 } |
| 429 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
430 static void ui_skinned_button_paint(UiSkinnedButton *button) { |
| 2822 | 431 GtkWidget *widget = GTK_WIDGET (button); |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
432 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
| 2822 | 433 |
|
2844
22da7cd0eca0
UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents:
2843
diff
changeset
|
434 //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
|
435 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
|
436 return; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
437 |
| 2833 | 438 if (button->redraw == TRUE) { |
| 439 button->redraw = FALSE; | |
|
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
440 |
| 2833 | 441 GdkPixmap *obj; |
| 442 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
|
443 switch (button->type) { |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
444 case TYPE_PUSH: |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
445 skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
446 button->pressed ? button->px : button->nx, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
447 button->pressed ? button->py : button->ny, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
448 0, 0, priv->w, priv->h); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
449 break; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
450 case TYPE_TOGGLE: |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
451 if (button->inside) |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
452 skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
453 button->pressed ? button->ppx : button->pnx, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
454 button->pressed ? button->ppy : button->pny, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
455 0, 0, priv->w, priv->h); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
456 else |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
457 skin_draw_pixmap(bmp_active_skin, obj, priv->gc, priv->skin_index2, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
458 button->pressed ? button->px : button->nx, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
459 button->pressed ? button->py : button->ny, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
460 0, 0, priv->w, priv->h); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
461 break; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
462 default: |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
463 break; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
464 } |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
465 |
| 2833 | 466 if(priv->double_size) { |
| 467 GdkImage *img, *img2x; | |
| 468 img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h); | |
| 469 img2x = create_dblsize_image(img); | |
| 470 gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL); | |
| 471 g_object_unref(img2x); | |
| 472 g_object_unref(img); | |
| 473 } else | |
| 474 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
|
475 |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
476 g_object_unref(obj); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
477 gtk_widget_queue_resize(widget); |
| 2833 | 478 } |
| 2822 | 479 } |
| 2833 | 480 |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
481 static void ui_skinned_button_redraw(UiSkinnedButton *button) { |
| 2833 | 482 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
483 ui_skinned_button_paint(button); |
| 2833 | 484 } |
|
2853
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
485 |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
486 |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
487 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
|
488 UiSkinnedButton *b = UI_SKINNED_BUTTON(button); |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
489 if (nx > -1) b->nx = nx; |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
490 if (ny > -1) b->ny = ny; |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
491 if (px > -1) b->px = px; |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
492 if (py > -1) b->py = py; |
|
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 |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
495 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
|
496 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
|
497 priv->skin_index1 = priv->skin_index2 = si; |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
498 } |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
499 |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
500 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
|
501 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
|
502 priv->skin_index1 = si; |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
503 } |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
504 |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
505 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
|
506 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
|
507 priv->skin_index2 = si; |
|
bec320cfcc12
use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents:
2844
diff
changeset
|
508 } |
