annotate src/audacious/legacy/ui_skinned_window.c @ 4807:859ef55f062c

Don't crash on an invalid interface.
author William Pitcock <nenolod@atheme.org>
date Thu, 16 Oct 2008 12:59:14 -0500
parents 885c21b8684e
children c10e53092037
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4700
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
1 /*
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
2 * Audacious: A cross-platform multimedia player
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
3 * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
4 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
7 * the Free Software Foundation; under version 3 of the License.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
8 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
12 * GNU General Public License for more details.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
13 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses>.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
16 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
17 * The Audacious team does not consider modular code linking to
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
18 * Audacious or using our public API to be a derived work.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
19 */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
20
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
21 #include "platform/smartinclude.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
22 #include "ui_skin.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
23
4795
885c21b8684e Only gtk.h should be included, as per -DGTK_DISABLE_SINGLE_INCLUDES (GTK+ 3 compatibility project).
Tony Vroon <chainsaw@gentoo.org>
parents: 4700
diff changeset
24 #include <gtk/gtk.h>
4700
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
25 #include <glib-object.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
26 #include <glib/gmacros.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
27 #include <string.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
28
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
29 #include "main.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
30 #include "ui_dock.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
31 #include "ui_skinned_window.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
32 #include "ui_playlist.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
33
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
34 static void ui_skinned_window_class_init(SkinnedWindowClass *klass);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
35 static void ui_skinned_window_init(GtkWidget *widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
36 static GtkWindowClass *parent = NULL;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
37
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
38 GType
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
39 ui_skinned_window_get_type(void)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
40 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
41 static GType window_type = 0;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
42
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
43 if (!window_type)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
44 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
45 static const GTypeInfo window_info =
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
46 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
47 sizeof (SkinnedWindowClass),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
48 NULL, /* base_init */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
49 NULL, /* base_finalize */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
50 (GClassInitFunc) ui_skinned_window_class_init,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
51 NULL, /* class_finalize */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
52 NULL, /* class_data */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
53 sizeof (SkinnedWindow),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
54 0, /* n_preallocs */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
55 (GInstanceInitFunc) ui_skinned_window_init
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
56 };
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
57
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
58 window_type =
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
59 g_type_register_static (GTK_TYPE_WINDOW, "SkinnedWindow_",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
60 &window_info, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
61 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
62
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
63 return window_type;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
64 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
65
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
66 static void
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
67 ui_skinned_window_map(GtkWidget *widget)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
68 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
69 (* GTK_WIDGET_CLASS (parent)->map) (widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
70
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
71 SkinnedWindow *window = SKINNED_WINDOW(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
72 if (window->type == WINDOW_MAIN)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
73 gtk_widget_shape_combine_mask(widget, skin_get_mask(aud_active_skin, SKIN_MASK_MAIN + cfg.player_shaded), 0, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
74 else if (window->type == WINDOW_EQ)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
75 gtk_widget_shape_combine_mask(widget, skin_get_mask(aud_active_skin, SKIN_MASK_EQ + cfg.equalizer_shaded), 0, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
76
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
77 gtk_window_set_keep_above(GTK_WINDOW(widget), cfg.always_on_top);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
78 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
79
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
80 static gboolean
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
81 ui_skinned_window_motion_notify_event(GtkWidget *widget,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
82 GdkEventMotion *event)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
83 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
84 if (dock_is_moving(GTK_WINDOW(widget)))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
85 dock_move_motion(GTK_WINDOW(widget), event);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
86
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
87 return FALSE;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
88 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
89
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
90 static gboolean ui_skinned_window_focus_in(GtkWidget *widget, GdkEventFocus *focus) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
91 gboolean val = GTK_WIDGET_CLASS (parent)->focus_in_event (widget, focus);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
92 gtk_widget_queue_draw(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
93 return val;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
94 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
95
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
96 static gboolean ui_skinned_window_focus_out(GtkWidget *widget, GdkEventFocus *focus) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
97 gboolean val = GTK_WIDGET_CLASS (parent)->focus_out_event (widget, focus);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
98 gtk_widget_queue_draw(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
99 return val;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
100 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
101
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
102 static gboolean ui_skinned_window_button_press(GtkWidget *widget, GdkEventButton *event) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
103 if (event->button == 1 && event->type == GDK_BUTTON_PRESS &&
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
104 (cfg.easy_move || cfg.equalizer_shaded || (event->y / cfg.scale_factor) < 14)) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
105 dock_move_press(get_dock_window_list(), GTK_WINDOW(widget),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
106 event, SKINNED_WINDOW(widget)->type == WINDOW_MAIN ? TRUE : FALSE);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
107 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
108
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
109 return TRUE;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
110 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
111
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
112 static gboolean ui_skinned_window_button_release(GtkWidget *widget, GdkEventButton *event) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
113 if (dock_is_moving(GTK_WINDOW(widget)))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
114 dock_move_release(GTK_WINDOW(widget));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
115
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
116 return TRUE;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
117 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
118
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
119 static gboolean ui_skinned_window_expose(GtkWidget *widget, GdkEventExpose *event) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
120 SkinnedWindow *window = SKINNED_WINDOW(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
121
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
122 GdkPixbuf *obj = NULL;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
123
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
124 gint width = 0, height = 0;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
125 switch (window->type) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
126 case WINDOW_MAIN:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
127 width = aud_active_skin->properties.mainwin_width;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
128 height = aud_active_skin->properties.mainwin_height;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
129 break;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
130 case WINDOW_EQ:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
131 width = 275 * (cfg.scaled ? cfg.scale_factor : 1);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
132 height = 116 * (cfg.scaled ? cfg.scale_factor : 1) ;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
133 break;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
134 case WINDOW_PLAYLIST:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
135 width = playlistwin_get_width();
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
136 height = cfg.playlist_height;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
137 break;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
138 default:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
139 return FALSE;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
140 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
141 obj = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
142
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
143 gboolean focus = gtk_window_has_toplevel_focus(GTK_WINDOW(widget));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
144
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
145 switch (window->type) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
146 case WINDOW_MAIN:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
147 skin_draw_pixbuf(widget, aud_active_skin, obj,SKIN_MAIN, 0, 0, 0, 0, width, height);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
148 skin_draw_mainwin_titlebar(aud_active_skin, obj, cfg.player_shaded, focus || !cfg.dim_titlebar);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
149 break;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
150 case WINDOW_EQ:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
151 skin_draw_pixbuf(widget, aud_active_skin, obj, SKIN_EQMAIN, 0, 0, 0, 0, width, height);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
152 if (focus || !cfg.dim_titlebar) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
153 if (!cfg.equalizer_shaded)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
154 skin_draw_pixbuf(widget, aud_active_skin, obj, SKIN_EQMAIN, 0, 134, 0, 0, width, 14);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
155 else
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
156 skin_draw_pixbuf(widget, aud_active_skin, obj, SKIN_EQ_EX, 0, 0, 0, 0, width, 14);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
157 } else {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
158 if (!cfg.equalizer_shaded)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
159 skin_draw_pixbuf(widget, aud_active_skin, obj, SKIN_EQMAIN, 0, 149, 0, 0, width, 14);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
160 else
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
161 skin_draw_pixbuf(widget, aud_active_skin, obj, SKIN_EQ_EX, 0, 15, 0, 0, width, 14);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
162 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
163 break;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
164 case WINDOW_PLAYLIST:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
165 focus |= !cfg.dim_titlebar;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
166 if (cfg.playlist_shaded) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
167 skin_draw_playlistwin_shaded(aud_active_skin, obj, width, focus);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
168 } else {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
169 skin_draw_playlistwin_frame(aud_active_skin, obj, width, cfg.playlist_height, focus);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
170 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
171 break;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
172 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
173
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
174 ui_skinned_widget_draw(GTK_WIDGET(window), obj, width, height,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
175 window->type != WINDOW_PLAYLIST && cfg.scaled);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
176
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
177 g_object_unref(obj);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
178
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
179 return FALSE;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
180 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
181
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
182 static void
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
183 ui_skinned_window_class_init(SkinnedWindowClass *klass)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
184 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
185 GtkWidgetClass *widget_class;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
186
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
187 widget_class = (GtkWidgetClass*) klass;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
188
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
189 parent = gtk_type_class(gtk_window_get_type());
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
190
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
191 widget_class->motion_notify_event = ui_skinned_window_motion_notify_event;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
192 widget_class->expose_event = ui_skinned_window_expose;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
193 widget_class->focus_in_event = ui_skinned_window_focus_in;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
194 widget_class->focus_out_event = ui_skinned_window_focus_out;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
195 widget_class->button_press_event = ui_skinned_window_button_press;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
196 widget_class->button_release_event = ui_skinned_window_button_release;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
197 widget_class->map = ui_skinned_window_map;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
198 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
199
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
200 void
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
201 ui_skinned_window_hide(SkinnedWindow *window)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
202 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
203 g_return_if_fail(SKINNED_CHECK_WINDOW(window));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
204
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
205 gtk_window_get_position(GTK_WINDOW(window), &window->x, &window->y);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
206 gtk_widget_hide(GTK_WIDGET(window));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
207 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
208
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
209 void
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
210 ui_skinned_window_show(SkinnedWindow *window)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
211 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
212 g_return_if_fail(SKINNED_CHECK_WINDOW(window));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
213
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
214 gtk_window_move(GTK_WINDOW(window), window->x, window->y);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
215 gtk_widget_show_all(GTK_WIDGET(window));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
216 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
217
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
218 static void
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
219 ui_skinned_window_init(GtkWidget *widget)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
220 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
221 SkinnedWindow *window;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
222 window = SKINNED_WINDOW(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
223 window->x = -1;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
224 window->y = -1;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
225 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
226
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
227 GtkWidget *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
228 ui_skinned_window_new(const gchar *wmclass_name)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
229 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
230 GtkWidget *widget = g_object_new(ui_skinned_window_get_type(), NULL);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
231 GtkWindow *window = GTK_WINDOW(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
232
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
233 window->type = SKINNED_WINDOW_TYPE;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
234
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
235 if (wmclass_name)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
236 gtk_window_set_wmclass(GTK_WINDOW(widget), wmclass_name, "Audacious");
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
237
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
238 gtk_widget_add_events(GTK_WIDGET(widget),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
239 GDK_FOCUS_CHANGE_MASK | GDK_BUTTON_MOTION_MASK |
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
240 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
241 GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK |
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
242 GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
243 gtk_widget_realize(GTK_WIDGET(widget));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
244
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
245 set_dock_window_list(dock_window_set_decorated(get_dock_window_list(),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
246 GTK_WINDOW(widget),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
247 cfg.show_wm_decorations));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
248 gtk_widget_set_app_paintable(GTK_WIDGET(widget), TRUE);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
249 gdk_window_set_back_pixmap(widget->window, NULL, FALSE);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
250 gtk_widget_shape_combine_mask(widget, NULL, 0, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
251
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
252 if (!strcmp(wmclass_name, "player"))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
253 SKINNED_WINDOW(widget)->type = WINDOW_MAIN;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
254 if (!strcmp(wmclass_name, "equalizer"))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
255 SKINNED_WINDOW(widget)->type = WINDOW_EQ;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
256 if (!strcmp(wmclass_name, "playlist"))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
257 SKINNED_WINDOW(widget)->type = WINDOW_PLAYLIST;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
258
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
259 /* GtkFixed hasn't got its GdkWindow, this means that it can be used to
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
260 display widgets while the logo below will be displayed anyway;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
261 however fixed positions are not that great, cause the button sizes may (will)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
262 vary depending on the gtk style used, so it's not possible to center
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
263 them unless a fixed width and heigth is forced (and this may bring to cutted
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
264 text if someone, i.e., uses a big font for gtk widgets);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
265 other types of container most likely have their GdkWindow, this simply
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
266 means that the logo must be drawn on the container widget, instead of the
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
267 window; otherwise, it won't be displayed correctly */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
268 SKINNED_WINDOW(widget)->fixed = gtk_fixed_new();
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
269 gtk_container_add(GTK_CONTAINER(widget), GTK_WIDGET(SKINNED_WINDOW(widget)->fixed));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
270 return widget;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
271 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
272
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
273 void ui_skinned_window_draw_all(GtkWidget *widget) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
274 if (SKINNED_WINDOW(widget)->type == WINDOW_MAIN)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
275 mainwin_refresh_hints();
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
276
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
277 gtk_widget_queue_draw(widget);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
278 GList *iter;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
279 for (iter = GTK_FIXED (SKINNED_WINDOW(widget)->fixed)->children; iter; iter = g_list_next (iter)) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
280 GtkFixedChild *child_data = (GtkFixedChild *) iter->data;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
281 GtkWidget *child = child_data->widget;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
282 gtk_widget_queue_draw(child);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
283 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
284 }