annotate src/audacious/ui_skinned_menurow.c @ 3236:74a999f3f4d2

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