annotate src/audacious/ui_new.c @ 4694:f0cc355c4660

Update time.
author William Pitcock <nenolod@atheme.org>
date Sat, 05 Jul 2008 17:23:12 -0500
parents a5707f571100
children 225f78715e65
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
4694
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
29 static GtkWidget *label_prev, *label_current, *label_next, *label_time;
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
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
32 static gulong slider_change_handler_id;
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
33 static gboolean slider_is_moving = FALSE;
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
34 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
35
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
36 static gboolean
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
37 window_delete()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
38 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
39 return FALSE;
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
40 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
41
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
42 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
43 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
44 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
45 gtk_main_quit();
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
46 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
47
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
48 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
49 button_open_pressed()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
50 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
51 run_filebrowser(TRUE);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
52 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
53
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
54 static void
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
55 button_add_pressed()
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
56 {
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
57 run_filebrowser(FALSE);
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
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
60 static void
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
61 button_play_pressed()
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
62 {
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
63 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
64 playback_initiate();
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
65 else
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
66 button_open_pressed();
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
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
69 static void
4685
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
70 button_pause_pressed()
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
71 {
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
72 playback_pause();
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
73 }
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
74
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
75 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
76 button_previous_pressed()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
77 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
78 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
79 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
80
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
81 static void
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
82 button_next_pressed()
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
83 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
84 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
85 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
86
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
87 static void
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
88 ui_set_current_song_title(gchar *text, gpointer user_data)
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
89 {
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
90 gchar *title = g_strdup_printf("<big>%s</big>", text);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
91 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
92 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
93 g_free(title);
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
94 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
95
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
96 static void
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
97 ui_playlist_update(Playlist *playlist, gpointer user_data)
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
98 {
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
99 gchar *text = playlist_get_info_text(playlist);
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
100 ui_set_current_song_title(text, NULL);
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
101 g_free(text);
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
102 }
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
103
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
104 static gboolean
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
105 ui_update_song_info(gpointer hook_data, gpointer user_data)
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
106 {
4694
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
107 gchar text[128];
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
108
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
109 if (!playback_get_playing())
4686
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
110 {
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
111 gtk_range_set_value(GTK_RANGE(slider), (gdouble)0);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
112 return FALSE;
4686
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
113 }
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
114
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
115 if (slider_is_moving)
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
116 return TRUE;
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
117
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
118 gint time = playback_get_time();
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
119 gint length = playback_get_length();
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
120
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
121 g_signal_handler_block(slider, slider_change_handler_id);
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
122 gtk_range_set_range(GTK_RANGE(slider), 0.0, (gdouble)length);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
123 gtk_range_set_value(GTK_RANGE(slider), (gdouble)time);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
124 g_signal_handler_unblock(slider, slider_change_handler_id);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
125
4694
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
126 time /= 1000;
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
127 length /= 1000;
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
128
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
129 g_snprintf(text, 128, "<tt><b>%d:%.2d/%d:%.2d</b></tt>", time / 60, time % 60,
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
130 length / 60, length % 60);
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
131 gtk_label_set_markup(GTK_LABEL(label_time), text);
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
132
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
133 return TRUE;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
134 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
135
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
136 static gboolean
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
137 ui_slider_value_changed_cb(GtkRange *range, gpointer user_data)
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
138 {
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
139 /* 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
140 * we add 1 to be on the safe side --mf0102 */
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
141 playback_seek(gtk_range_get_value(range)/1000 + 1);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
142
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
143 return TRUE;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
144 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
145
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
146 static gboolean
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
147 ui_slider_button_press_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
148 {
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
149 slider_is_moving = TRUE;
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
150 return FALSE;
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
151 }
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
152
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
153 static gboolean
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
154 ui_slider_button_release_cb(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
155 {
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
156 slider_is_moving = FALSE;
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
157 return FALSE;
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
158 }
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
159
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
160 static void
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
161 ui_playback_begin(gpointer hook_data, gpointer user_data)
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
162 {
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
163 ui_update_song_info(NULL, NULL);
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
164 update_song_timeout_source =
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
165 g_timeout_add_seconds(1, (GSourceFunc) ui_update_song_info, NULL);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
166 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
167
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
168 static void
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
169 ui_playback_stop(gpointer hook_data, gpointer user_data)
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
170 {
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
171 if (update_song_timeout_source) {
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
172 g_source_remove(update_song_timeout_source);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
173 update_song_timeout_source = 0;
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
174 }
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
175 }
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
176
4686
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
177 static void
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
178 ui_playback_end(gpointer hook_data, gpointer user_data)
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
179 {
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
180 ui_update_song_info(NULL, NULL);
4686
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
181 }
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
182
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
183 static GtkToolItem *
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
184 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
185 {
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
186 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
187 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
188 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
189 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
190 return button;
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
191 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
192
4674
b71d4f3f3afd make some functions static
mf0102 <0102@gmx.at>
parents: 4667
diff changeset
193 static GtkWidget *
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
194 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
195 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
196 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
197 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
198 return label;
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
199 }
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
200
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
201 static gboolean
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
202 _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
203 {
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
204 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
205 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
206 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
207 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
208 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
209
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
210 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
211 about current track */
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
212 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
213 and some control elements like position bar */
4694
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
214 GtkWidget *shbox; /* box for slider + time combo --nenolod */
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
215
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
216 GtkToolItem *button_open, *button_add,
4685
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
217 *button_play, *button_pause,
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
218 *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
219
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
220 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
4685
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
221 gtk_window_set_default_size(GTK_WINDOW(window), 450, 150);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
222 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
223 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
224 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
225 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
226
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
227
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
228 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
229 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
230
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
231
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
232 buttonbox = gtk_toolbar_new();
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
233 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
234 GTK_STOCK_OPEN);
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
235 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
236 GTK_STOCK_ADD);
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
237 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
238 GTK_STOCK_MEDIA_PLAY);
4685
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
239 button_pause = gtk_toolbar_button_add(buttonbox, button_pause_pressed,
06028c2c9068 make a "pause" button and increase default window size
mf0102 <0102@gmx.at>
parents: 4684
diff changeset
240 GTK_STOCK_MEDIA_PAUSE);
4680
8becf76f2906 add pbutton_add and button_play; display only button image
Tomasz Mon <desowin@gmail.com>
parents: 4674
diff changeset
241 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
242 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
243 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
244 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
245 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
246
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
247
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
248 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
249
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
250 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
251 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
252 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
253 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
254 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
255 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
256
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
265 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
266
4694
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
267 shbox = gtk_hbox_new(FALSE, 0);
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
268 gtk_box_pack_end(GTK_BOX(cvbox), shbox, TRUE, TRUE, 0);
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
269
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
270 slider = gtk_hscale_new(NULL);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
271 gtk_scale_set_draw_value(GTK_SCALE(slider), FALSE);
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
272 /* TODO: make this configureable */
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
273 gtk_range_set_update_policy(GTK_RANGE(slider), GTK_UPDATE_DELAYED);
4694
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
274 gtk_box_pack_start(GTK_BOX(shbox), slider, TRUE, TRUE, 0);
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
275
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
276 label_time = gtk_markup_label_new("<tt><b>0:00/0:00</b></tt>");
f0cc355c4660 Update time.
William Pitcock <nenolod@atheme.org>
parents: 4689
diff changeset
277 gtk_box_pack_start(GTK_BOX(shbox), label_time, FALSE, FALSE, 0);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
278
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
279 hook_associate("title change", (HookFunction) ui_set_current_song_title, NULL);
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
280 hook_associate("playback seek", (HookFunction) ui_update_song_info, NULL);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
281 hook_associate("playback begin", (HookFunction) ui_playback_begin, NULL);
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
282 hook_associate("playback stop", (HookFunction) ui_playback_stop, NULL);
4686
a6d1b4056966 reset slider when at end of song
mf0102 <0102@gmx.at>
parents: 4685
diff changeset
283 hook_associate("playback end", (HookFunction) ui_playback_end, NULL);
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
284 hook_associate("playlist update", (HookFunction) ui_playlist_update, NULL);
4682
f6ea8f18c241 add position slider
Tomasz Mon <desowin@gmail.com>
parents: 4681
diff changeset
285
4683
86e2ba287242 improve the position slider's behavior a bit and do some indentation
mf0102 <0102@gmx.at>
parents: 4682
diff changeset
286 slider_change_handler_id =
4687
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
287 g_signal_connect(slider, "value-changed",
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
288 G_CALLBACK(ui_slider_value_changed_cb), NULL);
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
289
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
290 g_signal_connect(slider, "button-press-event",
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
291 G_CALLBACK(ui_slider_button_press_cb), NULL);
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
292 g_signal_connect(slider, "button-release-event",
9e70ca57b5dd small adjustments to slider
Tomasz Mon <desowin@gmail.com>
parents: 4686
diff changeset
293 G_CALLBACK(ui_slider_button_release_cb), NULL);
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
294
4688
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
295 ui_playlist_update(playlist_get_active(), NULL);
b3e2ea3f9297 display what would be played if user presses play button
Tomasz Mon <desowin@gmail.com>
parents: 4687
diff changeset
296
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
297 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
298 gtk_main();
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
299
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
300 return TRUE;
4664
46c02b5589c2 commited initial version of new UI, which can be tested via "audacious -H"
mf0102 <0102@gmx.at>
parents:
diff changeset
301 }
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
302
4689
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
303 static gboolean
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
304 _ui_finalize(void)
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
305 {
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
306 hook_dissociate("title change", (HookFunction) ui_set_current_song_title);
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
307 hook_dissociate("playback seek", (HookFunction) ui_update_song_info);
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
308 hook_dissociate("playback begin", (HookFunction) ui_playback_begin);
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
309 hook_dissociate("playback stop", (HookFunction) ui_playback_stop);
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
310 hook_dissociate("playback end", (HookFunction) ui_playback_end);
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
311 hook_dissociate("playlist update", (HookFunction) ui_playlist_update);
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
312
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
313 return TRUE;
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
314 }
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
315
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
316 static Interface default_interface = {
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
317 .id = "default",
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
318 .desc = N_("Default Interface"),
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
319 .init = _ui_initialize,
4689
a5707f571100 dissociate hooks at _ui_finalize
Tomasz Mon <desowin@gmail.com>
parents: 4688
diff changeset
320 .fini = _ui_finalize,
4667
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
321 };
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
322
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
323 Interface *
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
324 ui_populate_default_interface(void)
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
325 {
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
326 interface_register(&default_interface);
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
327
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
328 return &default_interface;
2079f04c19e2 Use new Interface API.
William Pitcock <nenolod@atheme.org>
parents: 4664
diff changeset
329 }