annotate src/audacious/ui_skinned_number.c @ 4326:3af534ed9d20

cleaning up some cruft
author mf0102 <0102@gmx.at>
date Thu, 13 Mar 2008 16:41:48 +0100
parents 742f00832961
children de33c83aa06f
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 "util.h"
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30 #include "strings.h"
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 #include <string.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 #include <ctype.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 #include <gtk/gtkmain.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 #include <gtk/gtkmarshal.h>
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 #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
37
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 enum {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 DOUBLED,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 LAST_SIGNAL
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static GtkWidgetClass *parent_class = NULL;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53 static guint number_signals[LAST_SIGNAL] = { 0 };
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 GType ui_skinned_number_get_type() {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56 static GType number_type = 0;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 if (!number_type) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static const GTypeInfo number_info = {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 sizeof (UiSkinnedNumberClass),
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 NULL,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 (GClassInitFunc) ui_skinned_number_class_init,
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 NULL,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 sizeof (UiSkinnedNumber),
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 0,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 (GInstanceInitFunc) ui_skinned_number_init,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 };
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 number_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedNumber", &number_info, 0);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 return number_type;
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 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
76 GtkObjectClass *object_class;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 GtkWidgetClass *widget_class;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 object_class = (GtkObjectClass*) klass;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 widget_class = (GtkWidgetClass*) klass;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81 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
82
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 object_class->destroy = ui_skinned_number_destroy;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 widget_class->realize = ui_skinned_number_realize;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86 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
87 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
88 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
89
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
90 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
91
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
92 number_signals[DOUBLED] =
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
93 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
94 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
95 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
96 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 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
99 number->width = 9;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 number->height = 13;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 3002
diff changeset
103 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
104 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
105
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 number->x = x;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 number->y = y;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108 number->num = 0;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109 number->skin_index = si;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
111 number->scaled = FALSE;
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112
3939
d46d60247826 we don't need to store GtkFixed pointer, do we?
Tomasz Mon <desowin@gmail.com>
parents: 3933
diff changeset
113 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
114
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 return GTK_WIDGET(number);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 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
119 UiSkinnedNumber *number;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121 g_return_if_fail (object != NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 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
123
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
124 number = UI_SKINNED_NUMBER (object);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126 if (GTK_OBJECT_CLASS (parent_class)->destroy)
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 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
131 UiSkinnedNumber *number;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132 GdkWindowAttr attributes;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 gint attributes_mask;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 g_return_if_fail (widget != NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 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
137
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 number = UI_SKINNED_NUMBER(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 attributes.x = widget->allocation.x;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 attributes.y = widget->allocation.y;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 attributes.width = widget->allocation.width;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 attributes.height = widget->allocation.height;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 attributes.wclass = GDK_INPUT_OUTPUT;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 attributes.window_type = GDK_WINDOW_CHILD;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 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
148 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
149 attributes.visual = gtk_widget_get_visual(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 attributes.colormap = gtk_widget_get_colormap(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 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
153 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
154
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 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
156
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157 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
158 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 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
161 UiSkinnedNumber *number = UI_SKINNED_NUMBER(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
163 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
164 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
165 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 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
168 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 widget->allocation = *allocation;
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
171 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
172 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
173 if (GTK_WIDGET_REALIZED (widget))
3011
99865f696f13 don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents: 3005
diff changeset
174 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
175
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
176 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
177 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
178 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
180 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
181 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
182 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
183 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
184
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
185 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
4119
9d4b5cdae3ba oops, fix previous commit
Tomasz Mon <desowin@gmail.com>
parents: 4118
diff changeset
186 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
187
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
188 GdkPixbuf *obj;
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
189 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
190
3029
739516e45635 prevent from displaying mess
Tomasz Mon <desowin@gmail.com>
parents: 3024
diff changeset
191 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
192 number->num = 10;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
193
4195
2281da647da9 beggining of GdkPixbuf transition
Tomasz Mon <desowin@gmail.com>
parents: 4119
diff changeset
194 skin_draw_pixbuf(widget, bmp_active_skin, obj,
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195 number->skin_index, number->num * 9, 0,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
196 0, 0, number->width, number->height);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
198 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
199
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
200 g_object_unref(obj);
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
201
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
202 return FALSE;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
203 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
205 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
206 GtkWidget *widget = GTK_WIDGET (number);
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
207 number->scaled = !number->scaled;
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
208
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
209 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
210 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
211
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212 gtk_widget_queue_draw(GTK_WIDGET(number));
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
215 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
216 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
217 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
218
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
219 if (number->num == num)
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 return;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 number->num = num;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223 gtk_widget_queue_draw(GTK_WIDGET(number));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 }
3889
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
225
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
226 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
227 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
228 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
229
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
230 number->width = width;
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
231 number->height = height;
8f8d7ac51b08 fix skins with not-standard sized numbers pixmap
Tomasz Mon <desowin@gmail.com>
parents: 3840
diff changeset
232
4217
742f00832961 some more progress, but still broken
Cristi Magherusan <majeru@atheme.org>
parents: 4212
diff changeset
233 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
234 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
235 }