annotate src/audacious/ui_skinned_button.c @ 2910:6cd68e70e86d trunk

fix previous commit
author Tomasz Mon <desowin@gmail.com>
date Thu, 28 Jun 2007 17:05:29 +0200
parents 4829dd0c8975
children 4e71092ab29b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
1 /*
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team.
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
4 *
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
8 * (at your option) any later version.
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
9 *
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
13 * GNU General Public License for more details.
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
14 *
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
18 */
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
23
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
24 #include <gtk/gtkmain.h>
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
25 #include <gtk/gtkmarshal.h>
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
26 #include <gtk/gtkimage.h>
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
30
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
31 struct _UiSkinnedButtonPrivate {
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
32 //Skinned part
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
33 GtkWidget *image;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
34 GdkGC *gc;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
35 gint w;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
36 gint h;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
37 SkinPixmapId skin_index1;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
38 SkinPixmapId skin_index2;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
39 GtkWidget *fixed;
2827
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
40 gboolean double_size;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
41 };
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
42
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
43
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
57
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
0598469fe2a9 [svn] - cleaned up header
desowin
parents: 2833
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
77 static GType button_type = 0;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
78
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
79 if (!button_type) {
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
82 NULL, /* base_init */
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
85 NULL, /* class_finalize */
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
90 };
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
93 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
94 return button_type;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
95 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
98 GObjectClass *gobject_class;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
99 GtkObjectClass *object_class;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
100 GtkWidgetClass *widget_class;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
101 GtkContainerClass *container_class;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
102
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
103 gobject_class = G_OBJECT_CLASS(klass);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
104 object_class = (GtkObjectClass*)klass;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
105 widget_class = (GtkWidgetClass*)klass;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
106 container_class = (GtkContainerClass*)klass;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
107
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
124
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
125 klass->pressed = button_pressed;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
126 klass->released = button_released;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
130
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
131 button_signals[PRESSED] =
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
134 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
135
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
136 button_signals[RELEASED] =
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
139 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
140
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
141 button_signals[CLICKED] =
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
144 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
145
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
146 button_signals[DOUBLED] =
2827
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
149 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
157 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
161 priv->image = gtk_image_new();
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
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
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
165
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
166 g_object_set (priv->image, "visible", TRUE, NULL);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
167 gtk_container_add(GTK_CONTAINER(GTK_WIDGET(button)), priv->image);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
168
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
169 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_FOCUS);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
170 GTK_WIDGET_SET_FLAGS (button, GTK_NO_WINDOW);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
171 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
174 (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
175 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
178 GObject *object = (*G_OBJECT_CLASS (parent_class)->constructor)(type, n_construct_properties, construct_params);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
179
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
180 return object;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
181 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
185 GdkWindowAttr attrib;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
186
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
187 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
188
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
189 attrib.window_type = GDK_WINDOW_CHILD;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
190 attrib.x = widget->allocation.x;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
191 attrib.y = widget->allocation.y;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
192 attrib.width = widget->allocation.width;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
193 attrib.height = widget->allocation.height;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
194 attrib.wclass = GDK_INPUT_ONLY;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
195 attrib.event_mask = gtk_widget_get_events (widget);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
196 attrib.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
197
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
198 widget->window = gtk_widget_get_parent_window(widget);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
199 g_object_ref(widget->window);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
200
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
201 button->event_window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrib, GDK_WA_X | GDK_WA_Y);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
202 gdk_window_set_user_data (button->event_window, button);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
203 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
207
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
208 if (button->event_window) {
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
209 gdk_window_set_user_data (button->event_window, NULL);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
210 gdk_window_destroy (button->event_window);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
211 button->event_window = NULL;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
212 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
213
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
214 GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
215 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
220 GTK_WIDGET_CLASS (parent_class)->map(widget);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
221 gdk_window_show (button->event_window);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
222 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
227
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
228 if (button->event_window)
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
229 gdk_window_hide (button->event_window);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
230
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
231 GTK_WIDGET_CLASS (parent_class)->unmap (widget);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
232 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
235 if (GTK_WIDGET_DRAWABLE (widget))
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
236 (*GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
237
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
238 return FALSE;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
239 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
243 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
249 priv->gc = gc;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
250 priv->w = w;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
286 priv->skin_index1 = si;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
287 priv->skin_index2 = si;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
288 priv->fixed = fixed;
2827
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
289 priv->double_size = FALSE;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
290
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
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
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
293 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
294
2844
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
295 void ui_skinned_small_button_setup(GtkWidget *button, GtkWidget *fixed, GdkPixmap *parent, GdkGC *gc, gint x, gint y, gint w, gint h) {
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
296
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
297 UiSkinnedButton *sbutton = UI_SKINNED_BUTTON(button);
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
298 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE(sbutton);
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
299 priv->gc = gc;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
300 priv->w = w;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
301 priv->h = h;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
302 sbutton->x = x;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
303 sbutton->y = y;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
304 sbutton->type = TYPE_SMALL;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
305 priv->fixed = fixed;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
306 priv->double_size = FALSE;
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
307
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
308 gtk_widget_set_size_request(button, priv->w, priv->h);
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
309 gtk_fixed_put(GTK_FIXED(priv->fixed),GTK_WIDGET(button), sbutton->x, sbutton->y);
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
310 }
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
311
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
312 static void ui_skinned_button_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
313 UiSkinnedButton *button = UI_SKINNED_BUTTON (widget);
2910
6cd68e70e86d fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 2909
diff changeset
314 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
315 GtkAllocation child_alloc;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
316
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
317 widget->allocation = *allocation;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
318 if (GTK_BIN (button)->child) { //image should fill whole widget
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
319 child_alloc.x = widget->allocation.x;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
320 child_alloc.y = widget->allocation.y;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
321 child_alloc.width = MAX (1, widget->allocation.width);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
322 child_alloc.height = MAX (1, widget->allocation.height);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
323
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
324 gtk_widget_size_allocate (GTK_BIN (button)->child, &child_alloc);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
325 }
2828
0e460510d782 [svn] - fix audacious_pbutton_size_allocate
desowin
parents: 2827
diff changeset
326
0e460510d782 [svn] - fix audacious_pbutton_size_allocate
desowin
parents: 2827
diff changeset
327 if (GDK_IS_WINDOW(button->event_window))
0e460510d782 [svn] - fix audacious_pbutton_size_allocate
desowin
parents: 2827
diff changeset
328 gdk_window_move_resize (button->event_window, widget->allocation.x, widget->allocation.y,
0e460510d782 [svn] - fix audacious_pbutton_size_allocate
desowin
parents: 2827
diff changeset
329 widget->allocation.width, widget->allocation.height);
2910
6cd68e70e86d fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 2909
diff changeset
330
6cd68e70e86d fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 2909
diff changeset
331 button->x = widget->allocation.x/(priv->double_size ? 2 : 1);
6cd68e70e86d fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 2909
diff changeset
332 button->y = widget->allocation.y/(priv->double_size ? 2 : 1);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
333 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
334
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
335 static void button_pressed(UiSkinnedButton *button) {
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
336 button->button_down = TRUE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
337 ui_skinned_button_update_state(button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
338 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
339
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
340 static void button_released(UiSkinnedButton *button) {
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
341 button->button_down = FALSE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
342 if(button->hover) ui_skinned_button_clicked(button);
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
343 ui_skinned_button_update_state(button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
344 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
345
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
346 static void ui_skinned_button_update_state(UiSkinnedButton *button) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
347 ui_skinned_button_set_pressed(button, button->button_down);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
348 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
349
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
350 static void ui_skinned_button_set_pressed (UiSkinnedButton *button, gboolean pressed) {
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
351 if (pressed != button->pressed) {
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
352 button->pressed = pressed;
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
353 button->redraw = TRUE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
354 ui_skinned_button_paint(button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
355 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
356 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
357
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
358 static gboolean ui_skinned_button_button_press(GtkWidget *widget, GdkEventButton *event) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
359 UiSkinnedButton *button;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
360
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
361 if (event->type == GDK_BUTTON_PRESS) {
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
362 button = UI_SKINNED_BUTTON(widget);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
363
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
364 if (event->button == 1)
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
365 ui_skinned_button_pressed (button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
366 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
367
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
368 return TRUE;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
369 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
370
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
371 static gboolean ui_skinned_button_button_release(GtkWidget *widget, GdkEventButton *event) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
372 UiSkinnedButton *button;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
373 if (event->button == 1) {
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
374 button = UI_SKINNED_BUTTON(widget);
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
375 button->redraw = TRUE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
376 ui_skinned_button_released(button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
377 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
378
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
379 return TRUE;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
380 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
381
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
382 static void ui_skinned_button_pressed(UiSkinnedButton *button) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
383 g_return_if_fail(UI_IS_SKINNED_BUTTON(button));
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
384 g_signal_emit(button, button_signals[PRESSED], 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
385 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
386
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
387 static void ui_skinned_button_released(UiSkinnedButton *button) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
388 g_return_if_fail(UI_IS_SKINNED_BUTTON(button));
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
389 g_signal_emit(button, button_signals[RELEASED], 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
390 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
391
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
392 static void ui_skinned_button_clicked(UiSkinnedButton *button) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
393 g_return_if_fail(UI_IS_SKINNED_BUTTON(button));
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
394 button->inside = !button->inside;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
395 g_signal_emit(button, button_signals[CLICKED], 0);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
396 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
397
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
398 static gboolean ui_skinned_button_enter_notify(GtkWidget *widget, GdkEventCrossing *event) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
399 UiSkinnedButton *button;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
400
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
401 button = UI_SKINNED_BUTTON(widget);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
402 button->hover = TRUE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
403 if(button->button_down) ui_skinned_button_set_pressed(button, TRUE);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
404
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
405 return FALSE;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
406 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
407
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
408 static gboolean ui_skinned_button_leave_notify(GtkWidget *widget, GdkEventCrossing *event) {
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
409 UiSkinnedButton *button;
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
410
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
411 button = UI_SKINNED_BUTTON (widget);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
412 button->hover = FALSE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
413 if(button->button_down) ui_skinned_button_set_pressed(button, FALSE);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
414
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
415 return FALSE;
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
416 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
417
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
418 static void ui_skinned_button_add(GtkContainer *container, GtkWidget *widget) {
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
419 GTK_CONTAINER_CLASS (parent_class)->add(container, widget);
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
420 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
421
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
422 static void ui_skinned_button_toggle_doublesize(UiSkinnedButton *button) {
2827
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
423 GtkWidget *widget = GTK_WIDGET (button);
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
424 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
2827
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
425 priv->double_size = !priv->double_size;
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
426
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
427 gtk_widget_set_size_request(widget, priv->w*(1+priv->double_size), priv->h*(1+priv->double_size));
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
428 gtk_widget_set_uposition(widget, button->x*(1+priv->double_size), button->y*(1+priv->double_size));
9b27830ba765 [svn] implement toggle-double-size
desowin
parents: 2822
diff changeset
429
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
430 button->redraw = TRUE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
431 ui_skinned_button_paint(button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
432 }
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
433
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
434 static void ui_skinned_button_paint(UiSkinnedButton *button) {
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
435 GtkWidget *widget = GTK_WIDGET (button);
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
436 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
437
2844
22da7cd0eca0 UiSkinnedButton can now work as SButton
Tomasz Mon <desowin@gmail.com>
parents: 2843
diff changeset
438 //TYPE_SMALL doesn't have its own face
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
439 if (button->type == TYPE_SMALL || button->type == TYPE_NOT_SET)
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
440 return;
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
441
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
442 if (button->redraw == TRUE) {
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
443 button->redraw = FALSE;
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
444
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
445 GdkPixmap *obj;
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
446 obj = gdk_pixmap_new(NULL, priv->w, priv->h, gdk_rgb_get_visual()->depth);
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
447 switch (button->type) {
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
448 case TYPE_PUSH:
2854
9f37fd52e7d0 use correct skin indexes
Tomasz Mon <desowin@gmail.com>
parents: 2853
diff changeset
449 skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
9f37fd52e7d0 use correct skin indexes
Tomasz Mon <desowin@gmail.com>
parents: 2853
diff changeset
450 button->pressed ? priv->skin_index2 : priv->skin_index1,
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
451 button->pressed ? button->px : button->nx,
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
452 button->pressed ? button->py : button->ny,
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
453 0, 0, priv->w, priv->h);
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
454 break;
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
455 case TYPE_TOGGLE:
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
456 if (button->inside)
2854
9f37fd52e7d0 use correct skin indexes
Tomasz Mon <desowin@gmail.com>
parents: 2853
diff changeset
457 skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
9f37fd52e7d0 use correct skin indexes
Tomasz Mon <desowin@gmail.com>
parents: 2853
diff changeset
458 button->pressed ? priv->skin_index2 : priv->skin_index1,
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
459 button->pressed ? button->ppx : button->pnx,
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
460 button->pressed ? button->ppy : button->pny,
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
461 0, 0, priv->w, priv->h);
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
462 else
2854
9f37fd52e7d0 use correct skin indexes
Tomasz Mon <desowin@gmail.com>
parents: 2853
diff changeset
463 skin_draw_pixmap(bmp_active_skin, obj, priv->gc,
9f37fd52e7d0 use correct skin indexes
Tomasz Mon <desowin@gmail.com>
parents: 2853
diff changeset
464 button->pressed ? priv->skin_index2 : priv->skin_index1,
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
465 button->pressed ? button->px : button->nx,
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
466 button->pressed ? button->py : button->ny,
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
467 0, 0, priv->w, priv->h);
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
468 break;
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
469 default:
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
470 break;
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
471 }
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
472
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
473 if(priv->double_size) {
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
474 GdkImage *img, *img2x;
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
475 img = gdk_drawable_get_image(obj, 0, 0, priv->w, priv->h);
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
476 img2x = create_dblsize_image(img);
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
477 gtk_image_set(GTK_IMAGE(priv->image), img2x, NULL);
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
478 g_object_unref(img2x);
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
479 g_object_unref(img);
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
480 } else
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
481 gtk_image_set_from_pixmap(GTK_IMAGE(priv->image), obj, NULL);
2843
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
482
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
483 g_object_unref(obj);
91ef09fe7936 UiSkinnedButton can now work as TButton
Tomasz Mon <desowin@gmail.com>
parents: 2842
diff changeset
484 gtk_widget_queue_resize(widget);
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
485 }
2822
9cfdff8a8b37 [svn] and of course I forgot new files
desowin
parents:
diff changeset
486 }
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
487
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
488 static void ui_skinned_button_redraw(UiSkinnedButton *button) {
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
489 button->redraw = TRUE;
2842
c2622a939e9e rename audacious_pbutton to ui_skinned_button
Tomasz Mon <desowin@gmail.com>
parents: 2834
diff changeset
490 ui_skinned_button_paint(button);
2833
1e97a0a228b7 [svn] - reduce number of redraws
desowin
parents: 2831
diff changeset
491 }
2853
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
492
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
493
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
494 void ui_skinned_set_push_button_data(GtkWidget *button, gint nx, gint ny, gint px, gint py) {
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
495 UiSkinnedButton *b = UI_SKINNED_BUTTON(button);
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
496 if (nx > -1) b->nx = nx;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
497 if (ny > -1) b->ny = ny;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
498 if (px > -1) b->px = px;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
499 if (py > -1) b->py = py;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
500 }
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
501
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
502 void ui_skinned_button_set_skin_index(GtkWidget *button, SkinPixmapId si) {
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
503 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
504 priv->skin_index1 = priv->skin_index2 = si;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
505 }
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
506
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
507 void ui_skinned_button_set_skin_index1(GtkWidget *button, SkinPixmapId si) {
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
508 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
509 priv->skin_index1 = si;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
510 }
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
511
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
512 void ui_skinned_button_set_skin_index2(GtkWidget *button, SkinPixmapId si) {
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
513 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
514 priv->skin_index2 = si;
bec320cfcc12 use UiSkinnedButton instead of PButton in equalizerwin
Tomasz Mon <desowin@gmail.com>
parents: 2844
diff changeset
515 }
2901
5ed0674fabd6 replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 2854
diff changeset
516
5ed0674fabd6 replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 2854
diff changeset
517 void ui_skinned_button_move_relative(GtkWidget *button, gint x, gint y) {
5ed0674fabd6 replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 2854
diff changeset
518 UiSkinnedButton *b = UI_SKINNED_BUTTON(button);
5ed0674fabd6 replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 2854
diff changeset
519 UiSkinnedButtonPrivate *priv = UI_SKINNED_BUTTON_GET_PRIVATE (button);
5ed0674fabd6 replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 2854
diff changeset
520 gtk_fixed_move(GTK_FIXED(priv->fixed), button, b->x+x, b->y+y);
5ed0674fabd6 replace PButton in playlistwin with UiSkinnedButton, pbutton.c is no longer needed
Tomasz Mon <desowin@gmail.com>
parents: 2854
diff changeset
521 }