2313
|
1 /*
|
|
2 * Audacious - Cross-platform multimedia player
|
|
3 * Copyright (C) 2005-2007 Audacious development team
|
|
4 *
|
|
5 * Based on BMP:
|
|
6 * Copyright (C) 2003-2004 BMP development team
|
|
7 *
|
|
8 * Based on XMMS:
|
|
9 * Copyright (C) 1998-2003 XMMS development team
|
|
10 *
|
|
11 * This program is free software; you can redistribute it and/or modify
|
|
12 * it under the terms of the GNU General Public License as published by
|
|
13 * the Free Software Foundation; under version 2 of the License.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this program; if not, write to the Free Software
|
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
23 */
|
|
24
|
|
25 #ifdef HAVE_CONFIG_H
|
|
26 # include "config.h"
|
|
27 #endif
|
|
28
|
|
29 #include "ui_credits.h"
|
|
30
|
|
31 #include <glib.h>
|
|
32 #include <glib/gi18n.h>
|
|
33 #include <gtk/gtk.h>
|
|
34
|
|
35 #include "platform/smartinclude.h"
|
|
36
|
|
37 static GtkWidget *about_window = NULL;
|
|
38 static GdkPixbuf *about_pixbuf = NULL;
|
|
39 static GdkPixmap *mask_pixmap_window1 = NULL,
|
|
40 *mask_pixmap_window2 = NULL;
|
|
41 static GdkBitmap *mask_bitmap_window1 = NULL,
|
|
42 *mask_bitmap_window2 = NULL;
|
|
43
|
|
44 static const gchar *audacious_brief = N_("<big><b>Audacious %s</b></big>\n\n"
|
|
45 "Copyright (C) 2005-2007 Audacious Development Team");
|
|
46
|
|
47 static gboolean
|
|
48 on_about_window_expose(GtkWidget *widget, GdkEventExpose *expose, gpointer data)
|
|
49 {
|
|
50 g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE);
|
|
51
|
|
52 gdk_window_set_back_pixmap(GDK_WINDOW(widget->window), mask_pixmap_window2, 0);
|
|
53 gdk_window_clear(GDK_WINDOW(widget->window));
|
|
54
|
|
55 return FALSE;
|
|
56 }
|
|
57
|
|
58 static gboolean
|
|
59 on_about_window_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data)
|
|
60 {
|
|
61 g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE);
|
|
62
|
|
63 if (event->keyval == GDK_Escape)
|
|
64 {
|
|
65 gtk_widget_hide(widget);
|
|
66 }
|
|
67
|
|
68 return FALSE;
|
|
69 }
|
|
70
|
|
71 static gboolean
|
|
72 on_close_button_clicked (GtkWidget *widget, gpointer data)
|
|
73 {
|
|
74 g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE);
|
|
75
|
|
76 gtk_widget_hide(about_window);
|
|
77
|
|
78 return FALSE;
|
|
79 }
|
|
80
|
|
81 static gboolean
|
|
82 on_credits_button_clicked (GtkWidget *widget, gpointer data)
|
|
83 {
|
|
84 g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE);
|
|
85
|
|
86 show_credits_window();
|
|
87
|
|
88 return FALSE;
|
|
89 }
|
|
90
|
|
91 void
|
|
92 show_about_window(void)
|
|
93 {
|
|
94 GtkWidget *about_fixedbox;
|
|
95 GtkWidget *close_button;
|
|
96 GtkWidget *credits_button , *credits_button_hbox, *credits_button_image, *credits_button_label;
|
|
97 GtkWidget *brief_label;
|
|
98 gchar *filename = DATA_DIR G_DIR_SEPARATOR_S "images" G_DIR_SEPARATOR_S "about-logo.png";
|
|
99 gchar *text;
|
|
100 PangoAttrList *brief_label_attrs;
|
|
101 PangoAttribute *brief_label_foreground;
|
|
102
|
|
103 if (about_window != NULL)
|
|
104 {
|
|
105 gtk_window_present(GTK_WINDOW(about_window));
|
|
106 return;
|
|
107 }
|
|
108
|
|
109 about_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
110
|
|
111 g_signal_connect(about_window, "destroy",
|
|
112 G_CALLBACK(gtk_widget_destroyed), &about_window);
|
|
113
|
|
114 gtk_widget_realize(about_window);
|
|
115
|
|
116 about_pixbuf = gdk_pixbuf_new_from_file(filename, NULL);
|
|
117
|
|
118 gtk_widget_set_size_request(GTK_WIDGET (about_window),
|
|
119 gdk_pixbuf_get_width (about_pixbuf),
|
|
120 gdk_pixbuf_get_height (about_pixbuf));
|
|
121
|
|
122 gtk_widget_set_app_paintable(about_window, TRUE);
|
|
123 gtk_window_set_title(GTK_WINDOW(about_window), _("About Audacious"));
|
|
124 gtk_window_set_position(GTK_WINDOW(about_window), GTK_WIN_POS_CENTER);
|
|
125 gtk_window_set_resizable(GTK_WINDOW(about_window), FALSE);
|
|
126 gtk_window_set_decorated(GTK_WINDOW(about_window), FALSE);
|
|
127
|
|
128 gdk_pixbuf_render_pixmap_and_mask(about_pixbuf,
|
|
129 &mask_pixmap_window1,
|
|
130 &mask_bitmap_window1,
|
|
131 0);
|
|
132
|
|
133 gdk_pixbuf_render_pixmap_and_mask(about_pixbuf,
|
|
134 &mask_pixmap_window2,
|
|
135 &mask_bitmap_window2,
|
|
136 128);
|
|
137
|
|
138 gtk_widget_add_events(about_window, GDK_ALL_EVENTS_MASK);
|
|
139
|
|
140 g_signal_connect(about_window, "expose-event",
|
|
141 G_CALLBACK(on_about_window_expose), &about_window);
|
|
142
|
|
143 g_signal_connect(about_window, "key-press-event",
|
|
144 G_CALLBACK(on_about_window_key_press), &about_window);
|
|
145
|
|
146 gtk_widget_shape_combine_mask(GTK_WIDGET(about_window), mask_bitmap_window2, 0, 0);
|
|
147
|
|
148 /* GtkFixed hasn't got its GdkWindow, this means that it can be used to
|
|
149 display widgets while the logo below will be displayed anyway;
|
|
150 however fixed positions are not that great, cause the button sizes may (will)
|
|
151 vary depending on the gtk style used, so it's not possible to center
|
|
152 them unless a fixed width and heigth is forced (and this may bring to cutted
|
|
153 text if someone, i.e., uses a big font for gtk widgets);
|
|
154 other types of container most likely have their GdkWindow, this simply
|
|
155 means that the logo must be drawn on the container widget, instead of the
|
|
156 window; otherwise, it won't be displayed correctly */
|
|
157 about_fixedbox = gtk_fixed_new();
|
|
158 gtk_container_add( GTK_CONTAINER(about_window) , about_fixedbox );
|
|
159
|
|
160 close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
|
161
|
|
162 g_signal_connect(close_button, "clicked",
|
|
163 G_CALLBACK(on_close_button_clicked), NULL);
|
|
164
|
|
165 gtk_fixed_put( GTK_FIXED(about_fixedbox) , close_button , 375 , 220 );
|
|
166 gtk_widget_set_size_request( close_button , 100 , -1 );
|
|
167
|
|
168 credits_button = gtk_button_new();
|
|
169 credits_button_hbox = gtk_hbox_new( FALSE , 0 );
|
|
170 credits_button_image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_INFO , GTK_ICON_SIZE_BUTTON );
|
|
171 gtk_misc_set_alignment( GTK_MISC(credits_button_image) , 1 , 0.5 );
|
|
172 credits_button_label = gtk_label_new( _("Credits") );
|
|
173 gtk_misc_set_alignment( GTK_MISC(credits_button_label) , 0 , 0.5 );
|
|
174 gtk_box_pack_start( GTK_BOX(credits_button_hbox) , credits_button_image ,
|
|
175 TRUE , TRUE , 2 );
|
|
176 gtk_box_pack_start( GTK_BOX(credits_button_hbox) , credits_button_label ,
|
|
177 TRUE , TRUE , 2 );
|
|
178 gtk_container_add( GTK_CONTAINER(credits_button) , credits_button_hbox );
|
|
179
|
|
180 g_signal_connect(credits_button, "clicked",
|
|
181 G_CALLBACK(on_credits_button_clicked), NULL);
|
|
182
|
|
183 gtk_fixed_put( GTK_FIXED(about_fixedbox) , credits_button , 25 , 220 );
|
|
184 gtk_widget_set_size_request( credits_button , 100 , -1 );
|
|
185
|
|
186 brief_label = gtk_label_new(NULL);
|
|
187 text = g_strdup_printf(_(audacious_brief), VERSION);
|
|
188
|
|
189 brief_label_foreground = pango_attr_foreground_new(0, 0, 0);
|
|
190 brief_label_attrs = pango_attr_list_new();
|
|
191 pango_attr_list_insert(brief_label_attrs, brief_label_foreground);
|
|
192
|
|
193 gtk_label_set_markup(GTK_LABEL(brief_label), text);
|
|
194 gtk_label_set_justify(GTK_LABEL(brief_label), GTK_JUSTIFY_CENTER);
|
|
195 gtk_label_set_attributes(GTK_LABEL(brief_label), brief_label_attrs);
|
|
196 g_free(text);
|
|
197
|
|
198 gtk_fixed_put(GTK_FIXED(about_fixedbox), brief_label, 20, 145);
|
|
199 gtk_widget_set_size_request( brief_label , 460 , -1 );
|
|
200
|
|
201 gtk_widget_show_all(about_window);
|
|
202 gtk_window_present(GTK_WINDOW(about_window));
|
|
203 }
|