Mercurial > audlegacy
annotate src/audacious/ui_skinned_button.c @ 2843:91ef09fe7936 trunk
UiSkinnedButton can now work as TButton
| author | Tomasz Mon <desowin@gmail.com> |
|---|---|
| date | Sun, 17 Jun 2007 15:53:59 +0200 |
| parents | c2622a939e9e |
| children | 22da7cd0eca0 |
| 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 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
295 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
|
296 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget); |
| 2822 | 297 GtkAllocation child_alloc; |
| 298 | |
| 299 widget->allocation = *allocation; | |
| 300 if (GTK_BIN (button)->child) { //image should fill whole widget | |
| 301 child_alloc.x = widget->allocation.x; | |
| 302 child_alloc.y = widget->allocation.y; | |
| 303 child_alloc.width = MAX (1, widget->allocation.width); | |
| 304 child_alloc.height = MAX (1, widget->allocation.height); | |
| 305 | |
| 306 gtk_widget_size_allocate (GTK_BIN (button)->child, &child_alloc); | |
| 307 } | |
| 2828 | 308 |
| 309 if (GDK_IS_WINDOW(button->event_window)) | |
| 310 gdk_window_move_resize (button->event_window, widget->allocation.x, widget->allocation.y, | |
| 311 widget->allocation.width, widget->allocation.height); | |
| 2822 | 312 } |
| 313 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
314 static void button_pressed(UiSkinnedButton *button) { |
| 2822 | 315 button->button_down = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
316 ui_skinned_button_update_state(button); |
| 2822 | 317 } |
| 318 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
319 static void button_released(UiSkinnedButton *button) { |
| 2822 | 320 button->button_down = FALSE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
321 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
|
322 ui_skinned_button_update_state(button); |
| 2822 | 323 } |
| 324 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
325 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
|
326 ui_skinned_button_set_pressed(button, button->button_down); |
| 2822 | 327 } |
| 328 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
329 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed) { |
| 2822 | 330 if (pressed != button->pressed) { |
| 331 button->pressed = pressed; | |
| 2833 | 332 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
333 ui_skinned_button_paint(button); |
| 2822 | 334 } |
| 335 } | |
| 336 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
337 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
|
338 UiSkinnedButton *button; |
| 2822 | 339 |
| 340 if (event->type == GDK_BUTTON_PRESS) { | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
341 button = UI_SKINNED_BUTTON(widget); |
| 2822 | 342 |
| 343 if (event->button == 1) | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
344 ui_skinned_button_pressed (button); |
| 2822 | 345 } |
| 346 | |
| 347 return TRUE; | |
| 348 } | |
| 349 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
350 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
|
351 UiSkinnedButton *button; |
| 2822 | 352 if (event->button == 1) { |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
353 button = UI_SKINNED_BUTTON(widget); |
| 2833 | 354 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
355 ui_skinned_button_released(button); |
| 2822 | 356 } |
| 357 | |
| 358 return TRUE; | |
| 359 } | |
| 360 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
361 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
|
362 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
| 2822 | 363 g_signal_emit(button, button_signals[PRESSED], 0); |
| 364 } | |
| 365 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
366 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
|
367 g_return_if_fail(UI_IS_SKINNED_BUTTON(button)); |
| 2822 | 368 g_signal_emit(button, button_signals[RELEASED], 0); |
| 369 } | |
| 370 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
371 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
|
372 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
|
373 button->inside = !button->inside; |
| 2822 | 374 g_signal_emit(button, button_signals[CLICKED], 0); |
| 375 } | |
| 376 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
377 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
|
378 UiSkinnedButton *button; |
| 2822 | 379 |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
380 button = UI_SKINNED_BUTTON(widget); |
| 2822 | 381 button->hover = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
382 if(button->button_down) ui_skinned_button_set_pressed(button, TRUE); |
| 2822 | 383 |
| 384 return FALSE; | |
| 385 } | |
| 386 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
387 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
|
388 UiSkinnedButton *button; |
| 2822 | 389 |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
390 button = UI_SKINNED_BUTTON (widget); |
| 2822 | 391 button->hover = FALSE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
392 if(button->button_down) ui_skinned_button_set_pressed(button, FALSE); |
| 2822 | 393 |
| 394 return FALSE; | |
| 395 } | |
| 396 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
397 static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget) { |
| 2822 | 398 GTK_CONTAINER_CLASS (parent_class)->add(container, widget); |
| 399 } | |
| 400 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
401 static void ui_skinned_button_toggle_doublesize(UiSkinnedButton *button) { |
| 2827 | 402 GtkWidget *widget = GTK_WIDGET (button); |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
403 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
| 2827 | 404 priv->double_size = !priv->double_size; |
| 405 | |
| 406 gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size)); | |
| 407 gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size)); | |
| 408 | |
| 2833 | 409 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
410 ui_skinned_button_paint(button); |
| 2822 | 411 } |
| 412 | |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
413 static void ui_skinned_button_paint(UiSkinnedButton *button) { |
| 2822 | 414 GtkWidget *widget = GTK_WIDGET (button); |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
415 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button); |
| 2822 | 416 |
|
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
417 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
|
418 return; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
419 |
| 2833 | 420 if (button->redraw == TRUE) { |
| 421 button->redraw = FALSE; | |
|
2843
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
422 |
| 2833 | 423 GdkPixmap *obj; |
| 424 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
|
425 switch (button->type) { |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
426 case TYPE_PUSH: |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
427 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
|
428 button->pressed ? button->px : button->nx, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
429 button->pressed ? button->py : button->ny, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
430 0, 0, priv->w, priv->h); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
431 break; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
432 case TYPE_TOGGLE: |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
433 if (button->inside) |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
434 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
|
435 button->pressed ? button->ppx : button->pnx, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
436 button->pressed ? button->ppy : button->pny, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
437 0, 0, priv->w, priv->h); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
438 else |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
439 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
|
440 button->pressed ? button->px : button->nx, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
441 button->pressed ? button->py : button->ny, |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
442 0, 0, priv->w, priv->h); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
443 break; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
444 default: |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
445 break; |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
446 } |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
447 |
| 2833 | 448 if(priv->double_size) { |
| 449 GdkImage *img, *img2x; | |
| 450 img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h); | |
| 451 img2x = create_dblsize_image(img); | |
| 452 gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL); | |
| 453 g_object_unref(img2x); | |
| 454 g_object_unref(img); | |
| 455 } else | |
| 456 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
|
457 |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
458 g_object_unref(obj); |
|
91ef09fe7936
UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents:
2842
diff
changeset
|
459 gtk_widget_queue_resize(widget); |
| 2833 | 460 } |
| 2822 | 461 } |
| 2833 | 462 |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
463 static void ui_skinned_button_redraw(UiSkinnedButton *button) { |
| 2833 | 464 button->redraw = TRUE; |
|
2842
c2622a939e9e
rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents:
2834
diff
changeset
|
465 ui_skinned_button_paint(button); |
| 2833 | 466 } |
