annotate src/audacious/ui_new.c @ 4683:86e2ba287242

improve the position slider's behavior a bit and do some indentation
author mf0102 <0102@gmx.at>
date Sat, 05 Jul 2008 00:58:52 +0200
parents f6ea8f18c241
children 46044e2ae4f3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
2 * Copyright (C) 2005-2008 Audacious development team
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
3 *
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
6 * the Free Software Foundation; under version 3 of the License.
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
7 *
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
11 * GNU General Public License for more details.
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
12 *
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
13 * You should have received a copy of the GNU General Public License
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
14 * along with this program. If not, see <http://www.gnu.org/licenses>.
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
15 *
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
16 * The Audacious team does not consider modular code linking to
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
17 * Audacious or using our public API to be a derived work.
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
18 */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
19
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
20 #include <glib/gi18n.h>
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
21 #include <gtk/gtk.h>
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
22
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
23 #include "interface.h"
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
24 #include "playback.h"
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
25 #include "playlist.h"
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
26 #include "ui_fileopener.h"
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
27 #include "ui_new.h"
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
28
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
29 static GtkWidget *label_prev, *label_current, *label_next;
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
30 static GtkWidget *slider;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
31
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
32 gulong slider_change_handler_id;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
33 static gint update_song_timeout_source = 0;
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
34
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
35 static gboolean
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
36 window_delete()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
37 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
38 return FALSE;
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
39 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
40
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
41 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
42 window_destroy(GtkWidget *widget, gpointer data)
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
43 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
44 gtk_main_quit();
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
45 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
46
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
47 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
48 button_open_pressed()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
49 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
50 run_filebrowser(TRUE);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
51 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
52
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
53 static void
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
54 button_add_pressed()
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
55 {
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
56 run_filebrowser(FALSE);
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
57 }
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
58
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
59 static void
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
60 button_play_pressed()
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
61 {
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
62 if (playlist_get_length(playlist_get_active()))
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
63 playback_initiate();
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
64 else
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
65 button_open_pressed();
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
66 }
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
67
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
68 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
69 button_previous_pressed()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
70 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
71 playlist_prev(playlist_get_active());
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
72 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
73
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
74 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
75 button_next_pressed()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
76 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
77 playlist_next(playlist_get_active());
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
78 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
79
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
80 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
81 set_song_title(gpointer hook_data, gpointer user_data)
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
82 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
83 gchar *title =
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
84 g_strdup_printf("<big>%s</big>",
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
85 playlist_get_info_text(playlist_get_active()));
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
86 gtk_label_set_text(GTK_LABEL(label_current), title);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
87 g_object_set(G_OBJECT(label_current), "use-markup", TRUE, NULL);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
88 g_free(title);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
89 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
90
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
91 static gboolean
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
92 update_song_info(gpointer hook_data, gpointer user_data)
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
93 {
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
94 if (!playback_get_playing())
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
95 return FALSE;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
96
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
97 gint time = playback_get_time();
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
98 gint length = playback_get_length();
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
99
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
100 g_signal_handler_block(slider, slider_change_handler_id);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
101 gtk_range_set_range(GTK_RANGE(slider), (gdouble)0, (gdouble)length);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
102 gtk_range_set_value(GTK_RANGE(slider), (gdouble)time);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
103 g_signal_handler_unblock(slider, slider_change_handler_id);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
104
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
105 return TRUE;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
106 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
107
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
108 static gboolean
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
109 ui_slider_change_value_cb(GtkRange *range, GtkScrollType scroll,
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
110 gdouble value, gpointer user_data)
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
111 {
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
112 /* we are not allowed to do a playback_seek() with values < 1, therefore
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
113 * we add 1 to be on the safe side --mf0102 */
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
114 playback_seek(value/1000 + 1);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
115
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
116 return TRUE;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
117 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
118
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
119 static void
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
120 ui_playback_begin(gpointer hook_data, gpointer user_data)
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
121 {
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
122 update_song_info(NULL, NULL);
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
123 update_song_timeout_source =
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
124 g_timeout_add_seconds(1, (GSourceFunc) update_song_info, NULL);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
125 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
126
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
127 static void
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
128 ui_playback_stop(gpointer hook_data, gpointer user_data)
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
129 {
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
130 if (update_song_timeout_source) {
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
131 g_source_remove(update_song_timeout_source);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
132 update_song_timeout_source = 0;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
133 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
134 }
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
135
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
136 static GtkToolItem *
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
137 gtk_toolbar_button_add(GtkWidget *toolbar, void(*callback)(), const gchar *stock_id)
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
138 {
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
139 GtkToolItem *button = gtk_tool_button_new_from_stock(stock_id);
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
140 gtk_toolbar_insert(GTK_TOOLBAR(toolbar), button, -1);
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
141 g_signal_connect(G_OBJECT(button), "clicked",
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
142 G_CALLBACK(callback), NULL);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
143 return button;
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
144 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
145
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
146 static GtkWidget *
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
147 gtk_markup_label_new(const gchar *str)
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
148 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
149 GtkWidget *label = gtk_label_new(str);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
150 g_object_set(G_OBJECT(label), "use-markup", TRUE, NULL);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
151 return label;
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
152 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
153
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
154 static gboolean
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
155 _ui_initialize(void)
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
156 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
157 GtkWidget *window; /* the main window */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
158 GtkWidget *vbox; /* the main vertical box */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
159 GtkWidget *buttonbox; /* box containing buttons like "open", "next" */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
160 GtkWidget *pcnbox; /* box containing information about previous,
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
161 current and next track */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
162
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
163 GtkWidget *chbox; /* box containing album art and information
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
164 about current track */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
165 GtkWidget *cvbox; /* box containing information about current track
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
166 and some control elements like position bar */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
167
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
168 GtkToolItem *button_open, *button_add,
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
169 *button_play, *button_previous, *button_next;
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
170
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
171 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
172 g_signal_connect(G_OBJECT(window), "delete_event",
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
173 G_CALLBACK(window_delete), NULL);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
174 g_signal_connect(G_OBJECT(window), "destroy",
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
175 G_CALLBACK(window_destroy), NULL);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
176
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
177
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
178 vbox = gtk_vbox_new(FALSE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
179 gtk_container_add(GTK_CONTAINER(window), vbox);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
180
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
181
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
182 buttonbox = gtk_toolbar_new();
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
183 button_open = gtk_toolbar_button_add(buttonbox, button_open_pressed,
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
184 GTK_STOCK_OPEN);
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
185 button_add = gtk_toolbar_button_add(buttonbox, button_add_pressed,
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
186 GTK_STOCK_ADD);
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
187 button_play = gtk_toolbar_button_add(buttonbox, button_play_pressed,
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
188 GTK_STOCK_MEDIA_PLAY);
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
189 button_previous = gtk_toolbar_button_add(buttonbox, button_previous_pressed,
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
190 GTK_STOCK_MEDIA_PREVIOUS);
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
191 button_next = gtk_toolbar_button_add(buttonbox, button_next_pressed,
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
192 GTK_STOCK_MEDIA_NEXT);
4681
7453f5365b8c make button toolbar stay same size when resizing window vertically
Tomasz Mon <desowin@gmail.com>
parents: 4680
diff changeset
193 gtk_box_pack_start(GTK_BOX(vbox), buttonbox, FALSE, TRUE, 0);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
194
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
195
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
196 pcnbox = gtk_vbox_new(FALSE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
197
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
198 chbox = gtk_hbox_new(FALSE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
199 cvbox = gtk_vbox_new(FALSE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
200 label_current = gtk_markup_label_new("<big>Current: ?</big>");
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
201 gtk_misc_set_alignment(GTK_MISC(label_current), 0.0, 0.5);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
202 gtk_box_pack_start(GTK_BOX(cvbox), label_current, TRUE, TRUE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
203 gtk_box_pack_start(GTK_BOX(chbox), cvbox, TRUE, TRUE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
204
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
205 label_prev = gtk_markup_label_new("<small>Previous: ?</small>");
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
206 label_next = gtk_markup_label_new("<small>Next: ?</small>");
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
207 gtk_misc_set_alignment(GTK_MISC(label_prev), 0.0, 0.5);
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
208 gtk_misc_set_alignment(GTK_MISC(label_next), 1.0, 0.5);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
209 gtk_box_pack_start(GTK_BOX(pcnbox), label_prev, TRUE, TRUE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
210 gtk_box_pack_start(GTK_BOX(pcnbox), chbox, TRUE, TRUE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
211 gtk_box_pack_start(GTK_BOX(pcnbox), label_next, TRUE, TRUE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
212
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
213 gtk_box_pack_start(GTK_BOX(vbox), pcnbox, TRUE, TRUE, 0);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
214
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
215 slider = gtk_hscale_new(NULL);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
216 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
217 gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DISCONTINUOUS);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
218 gtk_box_pack_end(GTK_BOX(cvbox), slider, TRUE, TRUE, 0);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
219
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
220 hook_associate("title change", set_song_title, NULL);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
221 hook_associate("playback seek", (HookFunction) update_song_info, NULL);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
222 hook_associate("playback begin", (HookFunction) ui_playback_begin, NULL);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
223 hook_associate("playback stop", (HookFunction) ui_playback_stop, NULL);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
224
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
225 slider_change_handler_id =
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
226 g_signal_connect(slider, "change-value",
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
227 G_CALLBACK(ui_slider_change_value_cb), NULL);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
228
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
229 gtk_widget_show_all(window);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
230 gtk_main();
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
231
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
232 return TRUE;
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
233 }
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
234
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
235 static Interface default_interface = {
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
236 .id = "default",
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
237 .desc = N_("Default Interface"),
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
238 .init = _ui_initialize,
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
239 };
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
240
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
241 Interface *
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
242 ui_populate_default_interface(void)
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
243 {
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
244 interface_register(&default_interface);
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
245
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
246 return &default_interface;
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
247 }