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