Mercurial > audlegacy
comparison src/audacious/ui_new.c @ 4664:46c02b5589c2
commited initial version of new UI, which can be tested via "audacious -H"
author | mf0102 <0102@gmx.at> |
---|---|
date | Sun, 29 Jun 2008 01:27:24 +0200 |
parents | |
children | 2079f04c19e2 |
comparison
equal
deleted
inserted
replaced
4663:413cce2453b2 | 4664:46c02b5589c2 |
---|---|
1 /* Audacious - Cross-platform multimedia player | |
2 * Copyright (C) 2005-2008 Audacious development team | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; under version 3 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * You should have received a copy of the GNU General Public License | |
14 * along with this program. If not, see <http://www.gnu.org/licenses>. | |
15 * | |
16 * The Audacious team does not consider modular code linking to | |
17 * Audacious or using our public API to be a derived work. | |
18 */ | |
19 | |
20 #include <gtk/gtk.h> | |
21 | |
22 #include "playlist.h" | |
23 #include "ui_fileopener.h" | |
24 | |
25 static GtkWidget *label_prev, *label_current, *label_next; | |
26 | |
27 gboolean | |
28 window_delete() | |
29 { | |
30 return FALSE; | |
31 } | |
32 | |
33 void | |
34 window_destroy(GtkWidget *widget, gpointer data) | |
35 { | |
36 gtk_main_quit(); | |
37 } | |
38 | |
39 void | |
40 button_open_pressed() | |
41 { | |
42 run_filebrowser(TRUE); | |
43 } | |
44 | |
45 void | |
46 button_previous_pressed() | |
47 { | |
48 playlist_prev(playlist_get_active()); | |
49 } | |
50 | |
51 void | |
52 button_next_pressed() | |
53 { | |
54 playlist_next(playlist_get_active()); | |
55 } | |
56 | |
57 void | |
58 set_song_title(gpointer hook_data, gpointer user_data) | |
59 { | |
60 gchar *title = | |
61 g_strdup_printf("<big>%s</big>", | |
62 playlist_get_info_text(playlist_get_active())); | |
63 gtk_label_set_text(GTK_LABEL(label_current), title); | |
64 g_object_set(G_OBJECT(label_current), "use-markup", TRUE, NULL); | |
65 g_free(title); | |
66 } | |
67 | |
68 | |
69 GtkWidget * | |
70 gtk_box_button_add(GtkWidget *box, void(*callback)(), const gchar *stock_id) | |
71 { | |
72 GtkWidget *button = gtk_button_new_from_stock(stock_id); | |
73 gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0); | |
74 g_signal_connect(G_OBJECT(button), "button-press-event", | |
75 G_CALLBACK(callback), NULL); | |
76 return button; | |
77 } | |
78 | |
79 GtkWidget * | |
80 gtk_markup_label_new(const gchar *str) | |
81 { | |
82 GtkWidget *label = gtk_label_new(str); | |
83 g_object_set(G_OBJECT(label), "use-markup", TRUE, NULL); | |
84 return label; | |
85 } | |
86 | |
87 void | |
88 ui_initialize() | |
89 { | |
90 GtkWidget *window; /* the main window */ | |
91 GtkWidget *vbox; /* the main vertical box */ | |
92 GtkWidget *buttonbox; /* box containing buttons like "open", "next" */ | |
93 GtkWidget *pcnbox; /* box containing information about previous, | |
94 current and next track */ | |
95 | |
96 GtkWidget *chbox; /* box containing album art and information | |
97 about current track */ | |
98 GtkWidget *cvbox; /* box containing information about current track | |
99 and some control elements like position bar */ | |
100 | |
101 GtkWidget *button_open, *button_previous, *button_next; | |
102 | |
103 | |
104 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
105 g_signal_connect(G_OBJECT(window), "delete_event", | |
106 G_CALLBACK(window_delete), NULL); | |
107 g_signal_connect(G_OBJECT(window), "destroy", | |
108 G_CALLBACK(window_destroy), NULL); | |
109 | |
110 | |
111 vbox = gtk_vbox_new(FALSE, 0); | |
112 gtk_container_add(GTK_CONTAINER(window), vbox); | |
113 | |
114 | |
115 buttonbox = gtk_hbox_new(FALSE, 0); | |
116 button_open = gtk_box_button_add(buttonbox, button_open_pressed, | |
117 GTK_STOCK_OPEN); | |
118 button_previous = gtk_box_button_add(buttonbox, button_previous_pressed, | |
119 GTK_STOCK_MEDIA_PREVIOUS); | |
120 button_next = gtk_box_button_add(buttonbox, button_next_pressed, | |
121 GTK_STOCK_MEDIA_NEXT); | |
122 gtk_box_pack_start(GTK_BOX(vbox), buttonbox, TRUE, TRUE, 0); | |
123 | |
124 | |
125 pcnbox = gtk_vbox_new(FALSE, 0); | |
126 | |
127 chbox = gtk_hbox_new(FALSE, 0); | |
128 cvbox = gtk_vbox_new(FALSE, 0); | |
129 label_current = gtk_markup_label_new("<big>Current: ?</big>"); | |
130 gtk_box_pack_start(GTK_BOX(cvbox), label_current, TRUE, TRUE, 0); | |
131 gtk_box_pack_start(GTK_BOX(chbox), cvbox, TRUE, TRUE, 0); | |
132 | |
133 label_prev = gtk_markup_label_new("<small>Previous: ?</small>"); | |
134 label_next = gtk_markup_label_new("<small>Next: ?</small>"); | |
135 gtk_box_pack_start(GTK_BOX(pcnbox), label_prev, TRUE, TRUE, 0); | |
136 gtk_box_pack_start(GTK_BOX(pcnbox), chbox, TRUE, TRUE, 0); | |
137 gtk_box_pack_start(GTK_BOX(pcnbox), label_next, TRUE, TRUE, 0); | |
138 | |
139 gtk_box_pack_start(GTK_BOX(vbox), pcnbox, TRUE, TRUE, 0); | |
140 | |
141 hook_associate("title change", set_song_title, NULL); | |
142 | |
143 gtk_widget_show_all(window); | |
144 gtk_main(); | |
145 } |