annotate src/skins/ui_skinned_menurow.c @ 2888:7c7471554d88

convert some widgets into windowless ones
author Tomasz Mon <desowin@gmail.com>
date Tue, 12 Aug 2008 15:50:01 +0200
parents 5ae914e1b78c
children 3134a0987162
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
1 /*
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
2 * Audacious - a cross-platform multimedia player
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
3 * Copyright (c) 2007 Tomasz Moń
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
4 *
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
5 * Based on:
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
6 * BMP - Cross-platform multimedia player
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2003-2004 BMP development team.
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
8 * XMMS:
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
9 * Copyright (C) 1998-2003 XMMS development team.
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
10 *
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; under version 3 of the License.
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
14 *
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
19 *
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
22 *
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
23 * The Audacious team does not consider modular code linking to
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
24 * Audacious or using our public API to be a derived work.
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
25 */
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
26
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
27 #include <audacious/plugin.h>
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
28 #include "plugin.h"
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
29 #include "ui_skinned_menurow.h"
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
30
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
31 enum {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
32 DOUBLED,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
33 CHANGE,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
34 RELEASE,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
35 LAST_SIGNAL
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
36 };
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
37
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
38 static void ui_skinned_menurow_class_init (UiSkinnedMenurowClass *klass);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
39 static void ui_skinned_menurow_init (UiSkinnedMenurow *menurow);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
40 static void ui_skinned_menurow_destroy (GtkObject *object);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
41 static void ui_skinned_menurow_realize (GtkWidget *widget);
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
42 static void ui_skinned_menurow_unrealize (GtkWidget *widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
43 static void ui_skinned_menurow_map (GtkWidget *widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
44 static void ui_skinned_menurow_unmap (GtkWidget *widget);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
45 static void ui_skinned_menurow_size_request (GtkWidget *widget, GtkRequisition *requisition);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
46 static void ui_skinned_menurow_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
47 static gboolean ui_skinned_menurow_expose (GtkWidget *widget, GdkEventExpose *event);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
48 static MenuRowItem menurow_find_selected (UiSkinnedMenurow * mr, gint x, gint y);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
49 static gboolean ui_skinned_menurow_button_press (GtkWidget *widget, GdkEventButton *event);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
50 static gboolean ui_skinned_menurow_button_release (GtkWidget *widget, GdkEventButton *event);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
51 static gboolean ui_skinned_menurow_motion_notify (GtkWidget *widget, GdkEventMotion *event);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
52 static void ui_skinned_menurow_toggle_scaled (UiSkinnedMenurow *menurow);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
53
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
54 static GtkWidgetClass *parent_class = NULL;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
55 static guint menurow_signals[LAST_SIGNAL] = { 0 };
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
56
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
57 GType ui_skinned_menurow_get_type() {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
58 static GType menurow_type = 0;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
59 if (!menurow_type) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
60 static const GTypeInfo menurow_info = {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
61 sizeof (UiSkinnedMenurowClass),
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
62 NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
63 NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
64 (GClassInitFunc) ui_skinned_menurow_class_init,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
65 NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
66 NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
67 sizeof (UiSkinnedMenurow),
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
68 0,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
69 (GInstanceInitFunc) ui_skinned_menurow_init,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
70 };
2590
Tomasz Mon <desowin@gmail.com>
parents: 2582
diff changeset
71 menurow_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSkinnedMenurow", &menurow_info, 0);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
72 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
73
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
74 return menurow_type;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
75 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
76
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
77 static void ui_skinned_menurow_class_init(UiSkinnedMenurowClass *klass) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
78 GObjectClass *gobject_class;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
79 GtkObjectClass *object_class;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
80 GtkWidgetClass *widget_class;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
81
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
82 gobject_class = G_OBJECT_CLASS(klass);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
83 object_class = (GtkObjectClass*) klass;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
84 widget_class = (GtkWidgetClass*) klass;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
85 parent_class = gtk_type_class (gtk_widget_get_type ());
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
86
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
87 object_class->destroy = ui_skinned_menurow_destroy;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
88
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
89 widget_class->realize = ui_skinned_menurow_realize;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
90 widget_class->unrealize = ui_skinned_menurow_unrealize;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
91 widget_class->map = ui_skinned_menurow_map;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
92 widget_class->unmap = ui_skinned_menurow_unmap;
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
93 widget_class->expose_event = ui_skinned_menurow_expose;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
94 widget_class->size_request = ui_skinned_menurow_size_request;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
95 widget_class->size_allocate = ui_skinned_menurow_size_allocate;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
96 widget_class->button_press_event = ui_skinned_menurow_button_press;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
97 widget_class->button_release_event = ui_skinned_menurow_button_release;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
98 widget_class->motion_notify_event = ui_skinned_menurow_motion_notify;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
99
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
100 klass->scaled = ui_skinned_menurow_toggle_scaled;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
101 klass->change = NULL;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
102 klass->release = NULL;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
103
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
104 menurow_signals[DOUBLED] =
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
105 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
106 G_STRUCT_OFFSET (UiSkinnedMenurowClass, scaled), NULL, NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
107 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
108
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
109
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
110 menurow_signals[CHANGE] =
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
111 g_signal_new ("change", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
112 G_STRUCT_OFFSET (UiSkinnedMenurowClass, change), NULL, NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
113 gtk_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
114
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
115 menurow_signals[RELEASE] =
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
116 g_signal_new ("release", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
117 G_STRUCT_OFFSET (UiSkinnedMenurowClass, release), NULL, NULL,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
118 g_cclosure_marshal_VOID__UINT_POINTER, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
119
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
120 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
121
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
122 static void ui_skinned_menurow_init(UiSkinnedMenurow *menurow) {
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
123 menurow->scale_selected = config.scaled;
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
124 menurow->always_selected = config.always_on_top;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
125
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
126 menurow->event_window = NULL;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
127 GTK_WIDGET_SET_FLAGS(menurow, GTK_NO_WINDOW);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
128 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
129
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
130 GtkWidget* ui_skinned_menurow_new(GtkWidget *fixed, gint x, gint y, gint nx, gint ny, gint sx, gint sy, SkinPixmapId si) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
131 UiSkinnedMenurow *menurow = g_object_new (ui_skinned_menurow_get_type (), NULL);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
132
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
133 menurow->x = x;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
134 menurow->y = y;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
135 menurow->width = 8;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
136 menurow->height = 43;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
137 menurow->nx = nx;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
138 menurow->ny = ny;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
139 menurow->sx = sx;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
140 menurow->sy = sy;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
141 menurow->selected = MENUROW_NONE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
142
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
143 menurow->skin_index = si;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
144
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
145 menurow->scaled = FALSE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
146
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
147 gtk_fixed_put(GTK_FIXED(fixed), GTK_WIDGET(menurow), menurow->x, menurow->y);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
148
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
149 return GTK_WIDGET(menurow);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
150 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
151
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
152 static void ui_skinned_menurow_destroy(GtkObject *object) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
153 UiSkinnedMenurow *menurow;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
154
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
155 g_return_if_fail (object != NULL);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
156 g_return_if_fail (UI_SKINNED_IS_MENUROW (object));
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
157
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
158 menurow = UI_SKINNED_MENUROW (object);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
159
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
160 if (GTK_OBJECT_CLASS (parent_class)->destroy)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
161 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
162 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
163
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
164 static void ui_skinned_menurow_realize(GtkWidget *widget) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
165 UiSkinnedMenurow *menurow;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
166 GdkWindowAttr attributes;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
167 gint attributes_mask;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
168
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
169 g_return_if_fail (widget != NULL);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
170 g_return_if_fail (UI_SKINNED_IS_MENUROW(widget));
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
171
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
172 if (GTK_WIDGET_CLASS (parent_class)->realize)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
173 (* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
174 menurow = UI_SKINNED_MENUROW(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
175
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
176 attributes.x = widget->allocation.x;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
177 attributes.y = widget->allocation.y;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
178 attributes.width = widget->allocation.width;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
179 attributes.height = widget->allocation.height;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
180 attributes.wclass = GDK_INPUT_ONLY;
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
181 attributes.window_type = GDK_WINDOW_CHILD;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
182 attributes.event_mask = gtk_widget_get_events(widget);
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
183 attributes.event_mask |= GDK_BUTTON_PRESS_MASK |
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
184 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK;
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
185
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
186 attributes_mask = GDK_WA_X | GDK_WA_Y;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
187 menurow->event_window = gdk_window_new(widget->window, &attributes, attributes_mask);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
188
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
189 gdk_window_set_user_data(menurow->event_window, widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
190 }
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
191
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
192 static void ui_skinned_menurow_unrealize(GtkWidget *widget) {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
193 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW(widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
194
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
195 if ( menurow->event_window != NULL )
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
196 {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
197 gdk_window_set_user_data( menurow->event_window , NULL );
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
198 gdk_window_destroy( menurow->event_window );
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
199 menurow->event_window = NULL;
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
200 }
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
201
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
202 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
203 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
204 }
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
205
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
206 static void ui_skinned_menurow_map (GtkWidget *widget)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
207 {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
208 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW(widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
209
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
210 if (menurow->event_window != NULL)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
211 gdk_window_show (menurow->event_window);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
212
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
213 if (GTK_WIDGET_CLASS (parent_class)->map)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
214 (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
215 }
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
216
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
217 static void ui_skinned_menurow_unmap (GtkWidget *widget)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
218 {
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
219 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW(widget);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
220
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
221 if (menurow->event_window != NULL)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
222 gdk_window_hide (menurow->event_window);
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
223
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
224 if (GTK_WIDGET_CLASS (parent_class)->unmap)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
225 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
226 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
227
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
228 static void ui_skinned_menurow_size_request(GtkWidget *widget, GtkRequisition *requisition) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
229 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
230
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
231 requisition->width = menurow->width*(menurow->scaled ? config.scale_factor : 1);
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
232 requisition->height = menurow->height*(menurow->scaled ? config.scale_factor : 1);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
233 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
234
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
235 static void ui_skinned_menurow_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
236 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW (widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
237
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
238 widget->allocation = *allocation;
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
239 widget->allocation.x *= (menurow->scaled ? config.scale_factor : 1);
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
240 widget->allocation.y *= (menurow->scaled ? config.scale_factor : 1);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
241 if (GTK_WIDGET_REALIZED (widget))
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
242 if (menurow->event_window)
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
243 gdk_window_move_resize(menurow->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
244
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
245 menurow->x = widget->allocation.x/(menurow->scaled ? config.scale_factor : 1);
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
246 menurow->y = widget->allocation.y/(menurow->scaled ? config.scale_factor : 1);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
247 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
248
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
249 static gboolean ui_skinned_menurow_expose(GtkWidget *widget, GdkEventExpose *event) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
250 g_return_val_if_fail (widget != NULL, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
251 g_return_val_if_fail (UI_SKINNED_IS_MENUROW (widget), FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
252 g_return_val_if_fail (event != NULL, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
253
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
254 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW (widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
255 g_return_val_if_fail (menurow->width > 0 && menurow->height > 0, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
256
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
257 GdkPixbuf *obj = NULL;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
258 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, menurow->width, menurow->height);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
259
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
260 if (menurow->selected == MENUROW_NONE) {
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
261 if (config.always_show_cb || menurow->pushed)
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
262 skin_draw_pixbuf(widget, aud_active_skin, obj, menurow->skin_index,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
263 menurow->nx, menurow->ny, 0, 0, 8, 43);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
264 else
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
265 skin_draw_pixbuf(widget, aud_active_skin, obj, menurow->skin_index,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
266 menurow->nx + 8, menurow->ny, 0, 0, 8, 43);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
267 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
268 else {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
269 skin_draw_pixbuf(widget, aud_active_skin, obj, menurow->skin_index,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
270 menurow->sx + ((menurow->selected - 1) * 8),
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
271 menurow->sy, 0, 0, 8, 43);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
272 }
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
273 if (config.always_show_cb || menurow->pushed) {
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
274 if (menurow->always_selected)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
275 skin_draw_pixbuf(widget, aud_active_skin, obj, menurow->skin_index,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
276 menurow->sx + 8, menurow->sy + 10, 0, 10, 8, 8);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
277 if (menurow->scale_selected)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
278 skin_draw_pixbuf(widget, aud_active_skin, obj, menurow->skin_index,
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
279 menurow->sx + 24, menurow->sy + 26, 0, 26, 8, 8);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
280 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
281
2888
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
282 ui_skinned_widget_draw_with_coordinates(widget, obj, menurow->width, menurow->height,
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
283 widget->allocation.x,
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
284 widget->allocation.y,
7c7471554d88 convert some widgets into windowless ones
Tomasz Mon <desowin@gmail.com>
parents: 2590
diff changeset
285 menurow->scaled);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
286
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
287 g_object_unref(obj);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
288
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
289 return FALSE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
290 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
291
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
292 static MenuRowItem menurow_find_selected(UiSkinnedMenurow * mr, gint x, gint y) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
293 MenuRowItem ret = MENUROW_NONE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
294
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
295 x = x/(mr->scaled ? config.scale_factor : 1);
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
296 y = y/(mr->scaled ? config.scale_factor : 1);
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
297 if (x > 0 && x < 8) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
298 if (y >= 0 && y <= 10)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
299 ret = MENUROW_OPTIONS;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
300 if (y >= 10 && y <= 17)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
301 ret = MENUROW_ALWAYS;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
302 if (y >= 18 && y <= 25)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
303 ret = MENUROW_FILEINFOBOX;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
304 if (y >= 26 && y <= 33)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
305 ret = MENUROW_SCALE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
306 if (y >= 34 && y <= 42)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
307 ret = MENUROW_VISUALIZATION;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
308 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
309 return ret;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
310 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
311
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
312 static gboolean ui_skinned_menurow_button_press(GtkWidget *widget, GdkEventButton *event) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
313 g_return_val_if_fail (widget != NULL, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
314 g_return_val_if_fail (UI_SKINNED_IS_MENUROW (widget), FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
315 g_return_val_if_fail (event != NULL, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
316
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
317 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW (widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
318
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
319 if (event->type == GDK_BUTTON_PRESS) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
320 if (event->button == 1) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
321
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
322 menurow->pushed = TRUE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
323 menurow->selected = menurow_find_selected(menurow, event->x, event->y);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
324
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
325 gtk_widget_queue_draw(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
326 g_signal_emit_by_name(widget, "change", menurow->selected);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
327 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
328 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
329
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
330 return TRUE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
331 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
332
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
333 static gboolean ui_skinned_menurow_button_release(GtkWidget *widget, GdkEventButton *event) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
334 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
335 if (menurow->pushed) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
336 menurow->pushed = FALSE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
337
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
338 if (menurow->selected == MENUROW_ALWAYS)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
339 menurow->always_selected = !menurow->always_selected;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
340
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
341 if (menurow->selected == MENUROW_SCALE)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
342 menurow->scale_selected = !menurow->scale_selected;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
343
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
344 if ((int)(menurow->selected) != -1)
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
345 g_signal_emit_by_name(widget, "release", menurow->selected, event);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
346
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
347 menurow->selected = MENUROW_NONE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
348 gtk_widget_queue_draw(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
349 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
350
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
351 return TRUE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
352 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
353
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
354 static gboolean ui_skinned_menurow_motion_notify(GtkWidget *widget, GdkEventMotion *event) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
355 g_return_val_if_fail (widget != NULL, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
356 g_return_val_if_fail (UI_SKINNED_IS_MENUROW (widget), FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
357 g_return_val_if_fail (event != NULL, FALSE);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
358 UiSkinnedMenurow *menurow = UI_SKINNED_MENUROW(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
359
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
360 if (menurow->pushed) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
361 menurow->selected = menurow_find_selected(menurow, event->x, event->y);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
362
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
363 gtk_widget_queue_draw(widget);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
364 g_signal_emit_by_name(widget, "change", menurow->selected);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
365 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
366
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
367 return TRUE;
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
368 }
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
369
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
370 static void ui_skinned_menurow_toggle_scaled(UiSkinnedMenurow *menurow) {
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
371 GtkWidget *widget = GTK_WIDGET (menurow);
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
372
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
373 menurow->scaled = !menurow->scaled;
2582
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
374 gtk_widget_set_size_request(widget, menurow->width* (menurow->scaled ? config.scale_factor : 1),
9b4dfc007b87 use more local configuration options
Tomasz Mon <desowin@gmail.com>
parents: 2581
diff changeset
375 menurow->height * (menurow->scaled ? config.scale_factor : 1));
2581
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
376
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
377 gtk_widget_queue_draw(GTK_WIDGET(menurow));
6a0755e8c1b3 add ui_skinned_menurow
Tomasz Mon <desowin@gmail.com>
parents:
diff changeset
378 }