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