annotate src/audacious/ui_skinned_number.c @ 3369:676bfd7b6586 trunk

simplified the custom plugin menuentries system, expecially for ui files
author Giacomo Lozito <james@develia.org>
date Sun, 19 Aug 2007 13:57:53 +0200
parents f02623377013
children 46591501603e
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Audacious development team.
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);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 static void ui_skinned_number_toggle_doublesize (UiSkinnedNumber *number);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
90 klass->doubled = ui_skinned_number_toggle_doublesize;
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] =
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 g_signal_new ("toggle-double-size", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 G_STRUCT_OFFSET (UiSkinnedNumberClass, doubled), NULL, NULL,
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 number->fixed = fixed;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 number->double_size = FALSE;
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 gtk_fixed_put(GTK_FIXED(number->fixed), GTK_WIDGET(number), number->x, number->y);
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 return GTK_WIDGET(number);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119 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
120 UiSkinnedNumber *number;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 g_return_if_fail (object != NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
123 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
124
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
125 number = UI_SKINNED_NUMBER (object);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
126
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
127 if (GTK_OBJECT_CLASS (parent_class)->destroy)
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 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
132 UiSkinnedNumber *number;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 GdkWindowAttr attributes;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 gint attributes_mask;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 g_return_if_fail (widget != NULL);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 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
138
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 number = UI_SKINNED_NUMBER(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142 attributes.x = widget->allocation.x;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 attributes.y = widget->allocation.y;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144 attributes.width = widget->allocation.width;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 attributes.height = widget->allocation.height;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146 attributes.wclass = GDK_INPUT_OUTPUT;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 attributes.window_type = GDK_WINDOW_CHILD;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148 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
149 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
150 attributes.visual = gtk_widget_get_visual(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151 attributes.colormap = gtk_widget_get_colormap(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 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
154 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
155
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 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
157
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 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
159 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 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
162 UiSkinnedNumber *number = UI_SKINNED_NUMBER(widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 requisition->width = number->width*(1+number->double_size);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 requisition->height = number->height*(1+number->double_size);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168 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
169 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171 widget->allocation = *allocation;
3011
99865f696f13 don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents: 3005
diff changeset
172 widget->allocation.x *= (1+number->double_size);
99865f696f13 don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents: 3005
diff changeset
173 widget->allocation.y *= (1+number->double_size);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 if (GTK_WIDGET_REALIZED (widget))
3011
99865f696f13 don't use gtk_widget_set_uposition()
Tomasz Mon <desowin@gmail.com>
parents: 3005
diff changeset
175 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
176
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 number->x = widget->allocation.x/(number->double_size ? 2 : 1);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 number->y = widget->allocation.y/(number->double_size ? 2 : 1);
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 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
182 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
183 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
184 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
185
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
186 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
187
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
188 GdkPixmap *obj = NULL;
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 3002
diff changeset
189 GdkGC *gc;
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
190 obj = gdk_pixmap_new(NULL, number->width, number->height, gdk_rgb_get_visual()->depth);
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 3002
diff changeset
191 gc = gdk_gc_new(obj);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
192
3029
739516e45635 prevent from displaying mess
Tomasz Mon <desowin@gmail.com>
parents: 3024
diff changeset
193 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
194 number->num = 10;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
195
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 3002
diff changeset
196 skin_draw_pixmap(bmp_active_skin, obj, gc,
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
197 number->skin_index, number->num * 9, 0,
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
198 0, 0, number->width, number->height);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
199
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
200 GdkPixmap *image;
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
201 image = gdk_pixmap_new(NULL, number->width*(1+number->double_size),
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
202 number->height*(1+number->double_size),
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
203 gdk_rgb_get_visual()->depth);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
204
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
205 if (number->double_size) {
3103
1faf842dea49 we don't need create_dblsize_image() anymore
Tomasz Mon <desowin@gmail.com>
parents: 3031
diff changeset
206 image = create_dblsize_pixmap(obj);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
207 } else
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
208 gdk_draw_drawable (image, gc, obj, 0, 0, 0, 0, number->width, number->height);
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
209
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
210 g_object_unref(obj);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
211
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
212 gdk_draw_drawable (widget->window, gc, image, 0, 0, 0, 0,
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
213 number->width*(1+number->double_size), number->height*(1+number->double_size));
3005
3db40ad79fd9 request GdkGC when needed rather than carry one around
Tomasz Mon <desowin@gmail.com>
parents: 3002
diff changeset
214 g_object_unref(gc);
3031
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
215 g_object_unref(image);
229db6d72934 don't keep img
Tomasz Mon <desowin@gmail.com>
parents: 3029
diff changeset
216
3001
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
217 return FALSE;
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
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
220 static void ui_skinned_number_toggle_doublesize(UiSkinnedNumber *number) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
221 GtkWidget *widget = GTK_WIDGET (number);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
222 number->double_size = !number->double_size;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
223
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
224 gtk_widget_set_size_request(widget, number->width*(1+number->double_size), number->height*(1+number->double_size));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
225
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 gtk_widget_queue_draw(GTK_WIDGET(number));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227 }
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 void ui_skinned_number_set_number(GtkWidget *widget, gint num) {
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230 UiSkinnedNumber *number = UI_SKINNED_NUMBER (widget);
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
231
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
232 if (number->num == num)
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 return;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 number->num = num;
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 gtk_widget_queue_draw(GTK_WIDGET(number));
6d4b7b739232 fully implement UiSkinnedNumber, number.c no longer needed
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237 }