annotate src/audacious/ui_skinned_number.c @ 4690:cd1e4d4aa0b9

Take advantage of signalfd if available.
author William Pitcock <nenolod@atheme.org>
date Sat, 05 Jul 2008 16:55:24 -0500
parents cc6255f8b568
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
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: 3251
diff changeset
3 * Copyright (c) 2007 Tomasz Moń
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
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: 3103
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
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: 3103
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.
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include "ui_skinned_number.h"
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "main.h"
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "strings.h"
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include <string.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <ctype.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include <gtk/gtkmain.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include <gtk/gtkmarshal.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 #define UI_TYPE_SKINNED_NUMBER (ui_skinned_number_get_type())
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37 enum {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 DOUBLED,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 LAST_SIGNAL
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 };
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
42 static void ui_skinned_number_class_init (UiSkinnedNumberClass *klass);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 static void ui_skinned_number_init (UiSkinnedNumber *number);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
44 static void ui_skinned_number_destroy (GtkObject *object);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 static void ui_skinned_number_realize (GtkWidget *widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 static void ui_skinned_number_size_request (GtkWidget *widget, GtkRequisition *requisition);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 static void ui_skinned_number_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 static gboolean ui_skinned_number_expose (GtkWidget *widget, GdkEventExpose *event);
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
49 static void ui_skinned_number_toggle_scaled (UiSkinnedNumber *number);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 static GtkWidgetClass *parent_class = NULL;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static guint number_signals[LAST_SIGNAL] = { 0 };
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 GType ui_skinned_number_get_type() {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static GType number_type = 0;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 if (!number_type) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 static const GTypeInfo number_info = {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 sizeof (UiSkinnedNumberClass),
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 NULL,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 NULL,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 (GClassInitFunc) ui_skinned_number_class_init,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 NULL,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 NULL,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 sizeof (UiSkinnedNumber),
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 0,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 (GInstanceInitFunc) ui_skinned_number_init,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 };
4561
cc6255f8b568 Suffix all type names in core with _
Tomasz Mon <desowin@gmail.com>
parents: 4508
diff changeset
68 number_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedNumber_", &number_info, 0);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
71 return number_type;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 static void ui_skinned_number_class_init(UiSkinnedNumberClass *klass) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 GtkObjectClass *object_class;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76 GtkWidgetClass *widget_class;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 object_class = (GtkObjectClass*) klass;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 widget_class = (GtkWidgetClass*) klass;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 parent_class = gtk_type_class (gtk_widget_get_type ());
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 object_class->destroy = ui_skinned_number_destroy;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 widget_class->realize = ui_skinned_number_realize;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 widget_class->expose_event = ui_skinned_number_expose;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 widget_class->size_request = ui_skinned_number_size_request;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 widget_class->size_allocate = ui_skinned_number_size_allocate;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
89 klass->scaled = ui_skinned_number_toggle_scaled;
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
91 number_signals[DOUBLED] =
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
92 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
93 G_STRUCT_OFFSET (UiSkinnedNumberClass, scaled), NULL, NULL,
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 static void ui_skinned_number_init(UiSkinnedNumber *number) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 number->width = 9;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99 number->height = 13;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 3002
diff changeset
102 GtkWidget* ui_skinned_number_new(GtkWidget *fixed, gint x, gint y, SkinPixmapId si) {
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103 UiSkinnedNumber *number = g_object_new (ui_skinned_number_get_type (), NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 number->x = x;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 number->y = y;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 number->num = 0;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 number->skin_index = si;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
110 number->scaled = FALSE;
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111
3939
d46d60247826 we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents: 3933
diff changeset
112 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(number), number->x, number->y);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114 return GTK_WIDGET(number);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 static void ui_skinned_number_destroy(GtkObject *object) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 UiSkinnedNumber *number;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 g_return_if_fail (object != NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 g_return_if_fail (UI_SKINNED_IS_NUMBER (object));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 number = UI_SKINNED_NUMBER (object);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 if (GTK_OBJECT_CLASS (parent_class)->destroy)
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129 static void ui_skinned_number_realize(GtkWidget *widget) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 UiSkinnedNumber *number;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 GdkWindowAttr attributes;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 gint attributes_mask;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 g_return_if_fail (widget != NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 g_return_if_fail (UI_SKINNED_IS_NUMBER(widget));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 number = UI_SKINNED_NUMBER(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 attributes.x = widget->allocation.x;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 attributes.y = widget->allocation.y;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 attributes.width = widget->allocation.width;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 attributes.height = widget->allocation.height;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 attributes.wclass = GDK_INPUT_OUTPUT;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 attributes.window_type = GDK_WINDOW_CHILD;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 attributes.event_mask = gtk_widget_get_events(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 attributes.visual = gtk_widget_get_visual(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 attributes.colormap = gtk_widget_get_colormap(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154 widget->style = gtk_style_attach(widget->style, widget->window);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 gdk_window_set_user_data(widget->window, widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159 static void ui_skinned_number_size_request(GtkWidget *widget, GtkRequisition *requisition) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 UiSkinnedNumber *number = UI_SKINNED_NUMBER(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
162 requisition->width = number->width * ( number->scaled ? cfg.scale_factor : 1 );
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
163 requisition->height = number->height*( number->scaled ? cfg.scale_factor : 1);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 static void ui_skinned_number_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 widget->allocation = *allocation;
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
170 widget->allocation.x *= (number->scaled ? cfg.scale_factor: 1 );
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
171 widget->allocation.y *= (number->scaled ? cfg.scale_factor: 1 );
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
172 if (GTK_WIDGET_REALIZED (widget))
3011
99865f696f13 don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents: 3005
diff changeset
173 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
175 number->x = widget->allocation.x/(number->scaled ? cfg.scale_factor : 1);
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
176 number->y = widget->allocation.y/(number->scaled ? cfg.scale_factor : 1);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 static gboolean ui_skinned_number_expose(GtkWidget *widget, GdkEventExpose *event) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 g_return_val_if_fail (widget != NULL, FALSE);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 g_return_val_if_fail (UI_SKINNED_IS_NUMBER (widget), FALSE);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182 g_return_val_if_fail (event != NULL, FALSE);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
183
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
4119
9d4b5cdae3ba oops, fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 4118
diff changeset
185 g_return_val_if_fail (number->width > 0 && number->height > 0, FALSE);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
187 GdkPixbuf *obj;
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
188 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, number->width, number->height);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
189
3029
739516e45635 prevent from displaying mess
Tomasz Mon <desowin@gmail.com>
parents: 3024
diff changeset
190 if (number->num > 11 || number->num < 0)
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
191 number->num = 10;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192
4413
de33c83aa06f Huge renaming patch, changing BMP references to Audacious.
Matti Hamalainen <ccr@tnsp.org>
parents: 4217
diff changeset
193 skin_draw_pixbuf(widget, aud_active_skin, obj,
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
194 number->skin_index, number->num * 9, 0,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 0, 0, number->width, number->height);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
197 ui_skinned_widget_draw(widget, obj, number->width, number->height, number->scaled);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199 g_object_unref(obj);
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
200
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201 return FALSE;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
204 static void ui_skinned_number_toggle_scaled(UiSkinnedNumber *number) {
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205 GtkWidget *widget = GTK_WIDGET (number);
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
206 number->scaled = !number->scaled;
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
208 gtk_widget_set_size_request(widget, number->width * ( number->scaled ? cfg.scale_factor : 1),
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
209 number->height * ( number->scaled ? cfg.scale_factor : 1) );
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211 gtk_widget_queue_draw(GTK_WIDGET(number));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
214 void ui_skinned_number_set_number(GtkWidget *widget, gint num) {
3889
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
215 g_return_if_fail(UI_SKINNED_IS_NUMBER(widget));
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218 if (number->num == num)
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 return;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 number->num = num;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 gtk_widget_queue_draw(GTK_WIDGET(number));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 }
3889
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
224
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
225 void ui_skinned_number_set_size(GtkWidget *widget, gint width, gint height) {
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
226 g_return_if_fail(UI_SKINNED_IS_NUMBER(widget));
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
227 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
228
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
229 number->width = width;
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
230 number->height = height;
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
231
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
232 gtk_widget_set_size_request(widget, width*(number->scaled ? cfg.scale_factor : 1 ),
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
233 height*(number->scaled ? cfg.scale_factor : 1 ));
3889
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
234 }