annotate src/audacious/ui_skinned_horizontal_slider.c @ 3939:d46d60247826

we don't need to store GtkFixed pointer, do we?
author Tomasz Mon <desowin@gmail.com>
date Thu, 15 Nov 2007 12:38:47 +0100
parents 5a4ef76b1f42
children 1112f53ecc18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
3840
46591501603e Add my name in few places
Tomasz Mon <desowin@gmail.com>
parents: 3724
diff changeset
3 * Copyright (c) 2007 Tomasz Moń
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3105
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
3121
3b6d316f8b09 GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents: 3105
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
3123
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
22 *
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
23 * The Audacious team does not consider modular code linking to
f1c756f39e6c Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents: 3121
diff changeset
24 * Audacious or using our public API to be a derived work.
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_skinned_horizontal_slider.h"
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "main.h"
3059
f58cbfe8df1b use create_dblsize_image for doueblesizing
Tomasz Mon <desowin@gmail.com>
parents: 3053
diff changeset
29 #include "util.h"
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30
3105
1912eba1004b cleaning
Tomasz Mon <desowin@gmail.com>
parents: 3103
diff changeset
31 #define UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ui_skinned_horizontal_slider_get_type(), UiSkinnedHorizontalSliderPrivate))
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 typedef struct _UiSkinnedHorizontalSliderPrivate UiSkinnedHorizontalSliderPrivate;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 enum {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 MOTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 RELEASE,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 DOUBLED,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 LAST_SIGNAL
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 struct _UiSkinnedHorizontalSliderPrivate {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 SkinPixmapId skin_index;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 gboolean double_size;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 gint frame, frame_offset, frame_height, min, max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 gint knob_width, knob_height;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 gint position;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 gint width, height;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 gint (*frame_cb) (gint);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 static void ui_skinned_horizontal_slider_class_init (UiSkinnedHorizontalSliderClass *klass);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void ui_skinned_horizontal_slider_init (UiSkinnedHorizontalSlider *horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 static void ui_skinned_horizontal_slider_destroy (GtkObject *object);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static void ui_skinned_horizontal_slider_realize (GtkWidget *widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static void ui_skinned_horizontal_slider_size_request (GtkWidget *widget, GtkRequisition *requisition);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 static void ui_skinned_horizontal_slider_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 static gboolean ui_skinned_horizontal_slider_expose (GtkWidget *widget, GdkEventExpose *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static gboolean ui_skinned_horizontal_slider_button_press (GtkWidget *widget, GdkEventButton *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 static gboolean ui_skinned_horizontal_slider_button_release (GtkWidget *widget, GdkEventButton *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 static gboolean ui_skinned_horizontal_slider_motion_notify (GtkWidget *widget, GdkEventMotion *event);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 static void ui_skinned_horizontal_slider_toggle_doublesize (UiSkinnedHorizontalSlider *horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 static GtkWidgetClass *parent_class = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 static guint horizontal_slider_signals[LAST_SIGNAL] = { 0 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 GType ui_skinned_horizontal_slider_get_type() {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 static GType horizontal_slider_type = 0;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 if (!horizontal_slider_type) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 static const GTypeInfo horizontal_slider_info = {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 sizeof (UiSkinnedHorizontalSliderClass),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73 (GClassInitFunc) ui_skinned_horizontal_slider_class_init,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 sizeof (UiSkinnedHorizontalSlider),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 0,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 (GInstanceInitFunc) ui_skinned_horizontal_slider_init,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 };
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 horizontal_slider_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedHorizontalSlider", &horizontal_slider_info, 0);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 return horizontal_slider_type;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 static void ui_skinned_horizontal_slider_class_init(UiSkinnedHorizontalSliderClass *klass) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 GObjectClass *gobject_class;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88 GtkObjectClass *object_class;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 GtkWidgetClass *widget_class;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 gobject_class = G_OBJECT_CLASS(klass);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 object_class = (GtkObjectClass*) klass;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 widget_class = (GtkWidgetClass*) klass;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 parent_class = gtk_type_class (gtk_widget_get_type ());
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 object_class->destroy = ui_skinned_horizontal_slider_destroy;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 widget_class->realize = ui_skinned_horizontal_slider_realize;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 widget_class->expose_event = ui_skinned_horizontal_slider_expose;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 widget_class->size_request = ui_skinned_horizontal_slider_size_request;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 widget_class->size_allocate = ui_skinned_horizontal_slider_size_allocate;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 widget_class->button_press_event = ui_skinned_horizontal_slider_button_press;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 widget_class->button_release_event = ui_skinned_horizontal_slider_button_release;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 widget_class->motion_notify_event = ui_skinned_horizontal_slider_motion_notify;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 klass->motion = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 klass->release = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 klass->doubled = ui_skinned_horizontal_slider_toggle_doublesize;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 horizontal_slider_signals[MOTION] =
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 g_signal_new ("motion", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, motion), NULL, NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 horizontal_slider_signals[RELEASE] =
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 g_signal_new ("release", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, release), NULL, NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 horizontal_slider_signals[DOUBLED] =
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 G_STRUCT_OFFSET (UiSkinnedHorizontalSliderClass, doubled), NULL, NULL,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 g_type_class_add_private (gobject_class, sizeof (UiSkinnedHorizontalSliderPrivate));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 static void ui_skinned_horizontal_slider_init(UiSkinnedHorizontalSlider *horizontal_slider) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 horizontal_slider->pressed = FALSE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 GtkWidget* ui_skinned_horizontal_slider_new(GtkWidget *fixed, gint x, gint y, gint w, gint h, gint knx, gint kny,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 gint kpx, gint kpy, gint kw, gint kh, gint fh,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 gint fo, gint min, gint max, gint(*fcb) (gint), SkinPixmapId si) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 UiSkinnedHorizontalSlider *hs = g_object_new (ui_skinned_horizontal_slider_get_type (), NULL);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 hs->x = x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 hs->y = y;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 priv->width = w;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 priv->height = h;
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
143 hs->knob_nx = knx;
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
144 hs->knob_ny = kny;
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
145 hs->knob_px = kpx;
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
146 hs->knob_py = kpy;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 priv->knob_width = kw;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 priv->knob_height = kh;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 priv->frame_height = fh;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 priv->frame_offset = fo;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 priv->min = min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 priv->position = min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 priv->max = max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 priv->frame_cb = fcb;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 priv->frame = priv->frame_cb(0);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 priv->skin_index = si;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158
3939
d46d60247826 we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents: 3933
diff changeset
159 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(hs), hs->x, hs->y);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 return GTK_WIDGET(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 static void ui_skinned_horizontal_slider_destroy(GtkObject *object) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 UiSkinnedHorizontalSlider *horizontal_slider;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 g_return_if_fail (object != NULL);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (object));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (object);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 if (GTK_OBJECT_CLASS (parent_class)->destroy)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
173 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 static void ui_skinned_horizontal_slider_realize(GtkWidget *widget) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 UiSkinnedHorizontalSlider *horizontal_slider;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 GdkWindowAttr attributes;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 gint attributes_mask;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 g_return_if_fail (widget != NULL);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER(widget));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185 horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187 attributes.x = widget->allocation.x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188 attributes.y = widget->allocation.y;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189 attributes.width = widget->allocation.width;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 attributes.height = widget->allocation.height;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 attributes.wclass = GDK_INPUT_OUTPUT;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192 attributes.window_type = GDK_WINDOW_CHILD;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193 attributes.event_mask = gtk_widget_get_events(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
3051
befb8b7df9e6 correct sliders
Tomasz Mon <desowin@gmail.com>
parents: 3042
diff changeset
195 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 attributes.visual = gtk_widget_get_visual(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197 attributes.colormap = gtk_widget_get_colormap(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201
3052
b1b48ea20c16 Hooray, fix BadMatches
Tomasz Mon <desowin@gmail.com>
parents: 3051
diff changeset
202 widget->style = gtk_style_attach(widget->style, widget->window);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 gdk_window_set_user_data(widget->window, widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
206 static void ui_skinned_horizontal_slider_size_request(GtkWidget *widget, GtkRequisition *requisition) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209 requisition->width = priv->width*(1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 requisition->height = priv->height*(1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 static void ui_skinned_horizontal_slider_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 UiSkinnedHorizontalSlider *horizontal_slider = UI_SKINNED_HORIZONTAL_SLIDER (widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 widget->allocation = *allocation;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 widget->allocation.x *= (1+priv->double_size);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 widget->allocation.y *= (1+priv->double_size);
3332
7ed2be7e885e fix doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3305
diff changeset
220
3305
6cadc2ddf4cd revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents: 3251
diff changeset
221 if (priv->knob_height == priv->height)
3332
7ed2be7e885e fix doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3305
diff changeset
222 priv->knob_height = allocation->height/(priv->double_size ? 2 : 1);
7ed2be7e885e fix doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3305
diff changeset
223 priv->width = allocation->width/(priv->double_size ? 2 : 1);
7ed2be7e885e fix doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3305
diff changeset
224 priv->height = allocation->height/(priv->double_size ? 2 : 1);
3305
6cadc2ddf4cd revise 19ad8ea66a03: fix skins with non-standard size posbar
Tomasz Mon <desowin@gmail.com>
parents: 3251
diff changeset
225
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 if (GTK_WIDGET_REALIZED (widget))
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 horizontal_slider->x = widget->allocation.x/(priv->double_size ? 2 : 1);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 horizontal_slider->y = widget->allocation.y/(priv->double_size ? 2 : 1);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 static gboolean ui_skinned_horizontal_slider_expose(GtkWidget *widget, GdkEventExpose *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234 g_return_val_if_fail (widget != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 g_return_val_if_fail (event != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
239 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
240
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 GdkPixmap *obj = NULL;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
242 GdkGC *gc;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
243
3053
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
244 if (priv->position > priv->max) priv->position = priv->max;
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
245 else if (priv->position < priv->min) priv->position = priv->min;
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
246
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 obj = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248 gc = gdk_gc_new(obj);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249
3933
5a4ef76b1f42 beggining of better dealing with substandard winamp skins - if it doesn't break anything, why not commit this?
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
250 skin_draw_pixmap(widget, bmp_active_skin, obj, gc,
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 priv->skin_index, priv->frame_offset,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 priv->frame * priv->frame_height,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253 0, 0, priv->width, priv->height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 if (hs->pressed)
3933
5a4ef76b1f42 beggining of better dealing with substandard winamp skins - if it doesn't break anything, why not commit this?
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
255 skin_draw_pixmap(widget, bmp_active_skin, obj, gc,
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
256 priv->skin_index, hs->knob_px,
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
257 hs->knob_py, priv->position,
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 ((priv->height - priv->knob_height) / 2),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259 priv->knob_width, priv->knob_height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 else
3933
5a4ef76b1f42 beggining of better dealing with substandard winamp skins - if it doesn't break anything, why not commit this?
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
261 skin_draw_pixmap(widget, bmp_active_skin, obj, gc,
3042
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
262 priv->skin_index, hs->knob_nx,
01ae56759d15 mainwin_sposition is now UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents: 3040
diff changeset
263 hs->knob_ny, priv->position,
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 ((priv->height - priv->knob_height) / 2),
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 priv->knob_width, priv->knob_height);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266
3077
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
267 GdkPixmap *image = NULL;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 if (priv->double_size) {
3077
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
270 image = create_dblsize_pixmap(obj);
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
271 } else {
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
272 image = gdk_pixmap_new(NULL, priv->width, priv->height, gdk_rgb_get_visual()->depth);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
273 gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, priv->width, priv->height);
3077
4b076ad636e6 use GdkPixmaps for doublesizing
Tomasz Mon <desowin@gmail.com>
parents: 3059
diff changeset
274 }
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 g_object_unref(obj);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0,
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 priv->width*(1+priv->double_size), priv->height*(1+priv->double_size));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 g_object_unref(gc);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281 g_object_unref(image);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
282
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
283 return FALSE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
284 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
285
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286 static gboolean ui_skinned_horizontal_slider_button_press(GtkWidget *widget, GdkEventButton *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 g_return_val_if_fail (widget != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 g_return_val_if_fail (event != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER (widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(hs);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294 if (event->type == GDK_BUTTON_PRESS) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
295 if (event->button == 1) {
3600
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
296 gint x;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297
3600
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
298 x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2));
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
299 hs->pressed = TRUE;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300
3600
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
301 priv->position = x/(1+priv->double_size);
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
302 if (priv->position < priv->min)
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
303 priv->position = priv->min;
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
304 if (priv->position > priv->max)
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
305 priv->position = priv->max;
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
306 if (priv->frame_cb)
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
307 priv->frame = priv->frame_cb(priv->position);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308
3600
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
309 g_signal_emit_by_name(widget, "motion", priv->position);
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
310 gtk_widget_queue_draw(widget);
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
311 } else if (event->button == 3) {
3724
9a8e54ffdd76 prevent info text being stuck after changing volume
Tomasz Mon <desowin@gmail.com>
parents: 3600
diff changeset
312 if (hs->pressed) {
9a8e54ffdd76 prevent info text being stuck after changing volume
Tomasz Mon <desowin@gmail.com>
parents: 3600
diff changeset
313 hs->pressed = FALSE;
9a8e54ffdd76 prevent info text being stuck after changing volume
Tomasz Mon <desowin@gmail.com>
parents: 3600
diff changeset
314 g_signal_emit_by_name(widget, "release", priv->position);
9a8e54ffdd76 prevent info text being stuck after changing volume
Tomasz Mon <desowin@gmail.com>
parents: 3600
diff changeset
315 gtk_widget_queue_draw(widget);
9a8e54ffdd76 prevent info text being stuck after changing volume
Tomasz Mon <desowin@gmail.com>
parents: 3600
diff changeset
316 }
3600
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
317 event->x = event->x + hs->x;
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
318 event->y = event->y + hs->y;
aba660a4a15d Pop up playback menu if right clicked over playback-control widgets
Tomasz Mon <desowin@gmail.com>
parents: 3332
diff changeset
319 return FALSE;
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 return TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 static gboolean ui_skinned_horizontal_slider_button_release(GtkWidget *widget, GdkEventButton *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328
3724
9a8e54ffdd76 prevent info text being stuck after changing volume
Tomasz Mon <desowin@gmail.com>
parents: 3600
diff changeset
329 if (hs->pressed) {
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 hs->pressed = FALSE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 g_signal_emit_by_name(widget, "release", priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 return TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337 static gboolean ui_skinned_horizontal_slider_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 g_return_val_if_fail (widget != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340 g_return_val_if_fail (event != NULL, FALSE);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 if (hs->pressed) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 gint x;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346
3053
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
347 x = event->x - (priv->knob_width / (priv->double_size ? 1 : 2));
712b3d476e06 Correct slider behaviour in doublesize
Tomasz Mon <desowin@gmail.com>
parents: 3052
diff changeset
348 priv->position = x/(1+priv->double_size);
3040
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350 if (priv->position < priv->min)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 priv->position = priv->min;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353 if (priv->position > priv->max)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 priv->position = priv->max;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 priv->frame = priv->frame_cb(priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359 g_signal_emit_by_name(widget, "motion", priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 return TRUE;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366 static void ui_skinned_horizontal_slider_toggle_doublesize(UiSkinnedHorizontalSlider *horizontal_slider) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 GtkWidget *widget = GTK_WIDGET (horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(horizontal_slider);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 priv->double_size = !priv->double_size;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372 gtk_widget_set_size_request(widget, priv->width*(1+priv->double_size), priv->height*(1+priv->double_size));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
374 gtk_widget_queue_draw(GTK_WIDGET(horizontal_slider));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
375 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 void ui_skinned_horizontal_slider_set_position(GtkWidget *widget, gint pos) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 g_return_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget));
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
379 UiSkinnedHorizontalSlider *hs = UI_SKINNED_HORIZONTAL_SLIDER(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
380 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
381
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
382 if (pos == priv->position || hs->pressed)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
383 return;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
384
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
385 priv->position = pos;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
386
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
387 if (priv->frame_cb)
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
388 priv->frame = priv->frame_cb(priv->position);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
389
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
390 gtk_widget_queue_draw(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
391 }
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
392
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
393 gint ui_skinned_horizontal_slider_get_position(GtkWidget *widget) {
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
394 g_return_val_if_fail (UI_SKINNED_IS_HORIZONTAL_SLIDER (widget), -1);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
395 UiSkinnedHorizontalSliderPrivate *priv = UI_SKINNED_HORIZONTAL_SLIDER_GET_PRIVATE(widget);
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
396 return priv->position;
067e0186623a import UiSkinnedHorizontalSlider
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
397 }