annotate src/audacious/ui_lastfm.c @ 3294:2c167f1fbbe9 trunk

oops, I haven't noticed that credits are sorted alphabetically by surname
author Tomasz Mon <desowin@gmail.com>
date Fri, 10 Aug 2007 10:43:27 +0200
parents 1fef0ac7395e
children f985357757e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
1 #include <gtk/gtk.h>
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
2 #include <glib/gi18n.h>
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
3 #include <gdk/gdkkeysyms.h>
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
4 #include "configdb.h"
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
5 #include "playback.h"
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
6 #define DEBUG 1
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
7 typedef struct {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
8 gchar *username,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
9 *session;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
10 }last_fm;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
11
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
12 typedef struct
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
13 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
14 gchar *artist,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
15 *title;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
16 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
17 track_data;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
18
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
19 last_fm *login_data=NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
20 Playlist *current_playlist=NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
21 TitleInput *info = NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
22 GtkWidget *lastfm_url_entry, *lastfm_label,*artist_label,*title_label,*album_label, *gui_window=NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
23
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
24 gpointer open_url(gpointer url)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
25 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
26 gchar*s=g_new0(gchar,20);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
27 VFSFile* fd = vfs_fopen((gchar*)url,"r");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
28 if(fd)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
29 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
30 vfs_fgets(s,20,fd);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
31 g_print("Got data: '%s'\n",s);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
32 vfs_fclose(fd);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
33 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
34 g_free(s);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
35 g_free(url);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
36 return NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
37 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
38 void command(gchar *comm)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
39 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
40 /* get the session from mowgli*/
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
41 if(login_data->session)
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
42 {
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
43 g_free(login_data->session);
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
44 login_data->session=NULL;
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
45 }
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
46 login_data->session = g_strdup(mowgli_global_storage_get("lastfm_session_id"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
47 gchar *url=g_strdup_printf("http://ws.audioscrobbler.com/radio/control.php?session=%s&command=%s&debug=0",login_data->session,comm);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
48 g_thread_create(open_url,url,FALSE,NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
49 if(!g_str_has_prefix(comm,"love"))
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
50 g_thread_create((gpointer)playback_initiate,NULL,FALSE,NULL);
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
51 return;
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
52
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
53 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
54 static void change_track_data_cb(gpointer track, gpointer unused)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
55 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
56 gchar **inf,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
57 **t,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
58 *alb,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
59 *tr;
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
60 tr=g_strdup(((track_data*)track)->title);
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
61
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
62 if(tr==NULL)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
63 return ;
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
64 if(g_strrstr(tr,"last.fm")==NULL)
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
65 {
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
66 gtk_entry_set_text(GTK_ENTRY(lastfm_url_entry),"Not last.fm stream");
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
67 return;
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
68 }
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
69
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
70 #if DEBUG
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
71 g_print("New Track: %s \n",tr);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
72 #endif
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
73 if(g_str_has_prefix(tr,"lastfm://"))
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
74 return;
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
75 if(g_strrstr(tr,"Neighbour")!=NULL)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
76 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
77 gchar *temp=g_strdup_printf("lastfm://user/%s/neighbours", login_data->username);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
78 gtk_entry_set_text(GTK_ENTRY(lastfm_url_entry),temp);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
79 g_free(temp);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
80 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
81 if(g_strrstr(tr,"Personal")!=NULL)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
82 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
83 gchar *temp=g_strdup_printf("lastfm://user/%s/personal", login_data->username);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
84 gtk_entry_set_text(GTK_ENTRY(lastfm_url_entry),temp);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
85 g_free(temp);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
86 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
87
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
88 inf = g_strsplit(tr," - ",2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
89 if(inf[0]==NULL || inf[1]==NULL)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
90 return;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
91 gchar* artist_markup=g_strdup_printf("<b>Artist:</b> %s" ,inf[0]);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
92 gtk_label_set_markup(GTK_LABEL(artist_label),artist_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
93 g_free(artist_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
94
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
95 t = g_strsplit(inf[1], g_strrstr(inf[1],"("),2);
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
96 if(t[0]==NULL) return;
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
97 alb = g_strdup(mowgli_global_storage_get("lastfm_album"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
98
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
99 gchar* title_markup=g_strdup_printf("<b>Title:</b> %s" ,t[0]);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
100 gtk_label_set_markup( GTK_LABEL(title_label),title_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
101 g_free(title_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
102
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
103 gchar* album_markup=g_strdup_printf("<b>Album:</b> %s" ,alb);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
104 gtk_label_set_markup( GTK_LABEL(album_label),album_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
105 g_free(album_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
106
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
107 g_strfreev(inf);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
108 g_strfreev(t);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
109 g_free(alb);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
110 g_free(tr);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
111
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
112 return ;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
113 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
114
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
115 static void show_login_error_dialog(void)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
116 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
117 const gchar *markup =
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
118 N_("<b><big>Couldn't find your lastfm login data.</big></b>\n\n"
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
119 "Check if your Scrobbler's plugin login settings are configured properly.\n");
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
120
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
121 GtkWidget *dialog =
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
122 gtk_message_dialog_new_with_markup(NULL,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
123 GTK_DIALOG_DESTROY_WITH_PARENT,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
124 GTK_MESSAGE_ERROR,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
125 GTK_BUTTONS_OK,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
126 _(markup));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
127 gtk_dialog_run(GTK_DIALOG(dialog));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
128 gtk_widget_destroy(dialog);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
129 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
130
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
131
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
132
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
133 void init_last_fm(void)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
134 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
135 login_data = g_new0(last_fm,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
136 login_data->username = NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
137 login_data->session = NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
138 ConfigDb *cfg = NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
139
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
140 if ((cfg = bmp_cfg_db_open()) != NULL)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
141 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
142 login_data->username=NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
143 bmp_cfg_db_get_string(cfg, "audioscrobbler","username",
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
144 &login_data->username);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
145 if(login_data->username==NULL)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
146 show_login_error_dialog();
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
147 g_free(cfg);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
148 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
149
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
150 current_playlist = g_new0(Playlist,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
151 current_playlist = playlist_get_active();
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
152 track_data * tr=g_new0(track_data,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
153 tr->title =NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
154 hook_associate( "playlist set info" , change_track_data_cb ,tr);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
155
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
156 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
157
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
158 /*event callback functions*/
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
159
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
160 gboolean love_press_callback(GtkWidget *love)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
161 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
162 command("love");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
163 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
164 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
165
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
166 gboolean skip_press_callback(GtkWidget *skip)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
167 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
168 command("skip");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
169 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
170 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
171 gboolean ban_press_callback(GtkWidget *ban)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
172 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
173 command("ban");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
174 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
175 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
176
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
177
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
178 gboolean add_press_callback(GtkWidget *love)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
179 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
180 gchar *text=NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
181 gint poz=0;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
182 text = g_strdup(gtk_entry_get_text(GTK_ENTRY(lastfm_url_entry)));
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
183 if(playback_get_playing()==TRUE)
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
184 playback_stop();
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
185
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
186 poz = playlist_get_length(current_playlist);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
187 playlist_add_url(current_playlist, text);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
188 sleep(1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
189 playlist_set_position(current_playlist, poz);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
190 playback_initiate();
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
191 g_free(text);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
192 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
193 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
194
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
195 gboolean neighbours_press_callback(GtkWidget *love)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
196 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
197 gchar *temp=g_strdup_printf("lastfm://user/%s/neighbours", login_data->username);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
198 gtk_entry_set_text(GTK_ENTRY(lastfm_url_entry),temp);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
199 g_free(temp);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
200 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
201 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
202
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
203 gboolean personal_press_callback(GtkWidget *love)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
204 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
205 gchar *per=g_strdup_printf("lastfm://user/%s/personal", login_data->username);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
206 gtk_entry_set_text(GTK_ENTRY(lastfm_url_entry),per);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
207 g_free(per);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
208 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
209 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
210
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
211 gboolean delete_window_callback(GtkWidget *window)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
212 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
213 gtk_widget_destroy(window);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
214 window=NULL;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
215 return FALSE;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
216 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
217 static gboolean keypress_callback(GtkWidget * widget, GdkEventKey * event, gpointer data)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
218 {
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
219 switch (event->keyval)
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
220 {
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
221 case GDK_Escape:
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
222 gtk_widget_hide_all(widget);
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
223 break;
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
224 default:
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
225 return FALSE;
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
226 }
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
227 return TRUE;
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
228 }
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
229
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
230
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
231 GtkWidget *ui_lastfm_create(void)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
232 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
233 GtkWidget *window;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
234 GtkWidget *box1,*box2,*vboxw,*vbox1,*vbox2,*v_hbox1,*v_hbox2,*labelbox;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
235 GtkWidget *love,*ban,*skip,*add,*neighbours,*personal;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
236
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
237 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
238 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
239 gtk_window_set_title(GTK_WINDOW(window), N_("Audacious last.fm radio tuner"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
240 lastfm_label = gtk_label_new_with_mnemonic(N_("Station:"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
241 title_label = gtk_label_new(NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
242 artist_label = gtk_label_new(NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
243 album_label = gtk_label_new(NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
244 lastfm_url_entry = gtk_entry_new();
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
245 gtk_editable_set_editable (GTK_EDITABLE(lastfm_url_entry),TRUE);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
246 gchar* artist_markup=g_strdup("<b>Artist:</b>");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
247 gtk_label_set_markup(GTK_LABEL(artist_label),artist_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
248 g_free(artist_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
249
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
250 gchar* title_markup=g_strdup("<b>Title:</b>");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
251 gtk_label_set_markup( GTK_LABEL(title_label),title_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
252 g_free(title_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
253
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
254 gchar* album_markup=g_strdup_printf("<b>Album:</b>");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
255 gtk_label_set_markup( GTK_LABEL(album_label),album_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
256 g_free(album_markup);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
257
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
258 love = gtk_button_new_with_label (N_("Love"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
259 ban = gtk_button_new_with_label (N_("Ban"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
260 skip = gtk_button_new_with_label (N_("Skip"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
261 add = gtk_button_new_with_label (N_("Tune in"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
262
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
263 neighbours = gtk_button_new_with_label(N_("Neighbours' radio"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
264 personal = gtk_button_new_with_label(N_("Personal radio"));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
265
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
266 box1 = gtk_hbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
267 box2 = gtk_hbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
268
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
269 vboxw = gtk_vbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
270
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
271 vbox1 = gtk_vbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
272 vbox2 = gtk_vbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
273
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
274 v_hbox1 = gtk_vbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
275 v_hbox2 = gtk_hbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
276 labelbox = gtk_vbox_new(FALSE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
277
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
278 gtk_misc_set_alignment(GTK_MISC(artist_label),0,0);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
279 gtk_misc_set_alignment(GTK_MISC(title_label),0,0);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
280 gtk_misc_set_alignment(GTK_MISC(album_label),0,0);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
281
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
282 gtk_box_pack_start(GTK_BOX(vboxw),box1,FALSE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
283 gtk_box_pack_end(GTK_BOX(vboxw),box2,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
284
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
285 gtk_box_pack_start(GTK_BOX(box1),lastfm_label,FALSE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
286 gtk_box_pack_start(GTK_BOX(box1),lastfm_url_entry,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
287 gtk_box_pack_start(GTK_BOX(box1),add,FALSE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
288
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
289 gtk_box_set_spacing(GTK_BOX(box1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
290 gtk_container_set_border_width(GTK_CONTAINER(box1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
291
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
292 gtk_box_pack_start(GTK_BOX(box2),vbox1,FALSE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
293 gtk_box_pack_start(GTK_BOX(box2),vbox2,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
294
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
295 gtk_box_pack_start(GTK_BOX(vbox1),neighbours,FALSE,TRUE,3);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
296 gtk_box_pack_start(GTK_BOX(vbox1),personal,FALSE,TRUE,3);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
297 gtk_box_set_spacing(GTK_BOX(vbox1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
298 gtk_container_set_border_width(GTK_CONTAINER(vbox1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
299
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
300 gtk_box_pack_start(GTK_BOX(vbox2),v_hbox1,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
301 gtk_box_pack_start(GTK_BOX(vbox2),v_hbox2,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
302
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
303 gtk_box_pack_start(GTK_BOX(v_hbox1),artist_label,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
304 gtk_box_pack_start(GTK_BOX(v_hbox1),title_label,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
305 gtk_box_pack_start(GTK_BOX(v_hbox1),album_label,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
306 gtk_box_set_spacing(GTK_BOX(v_hbox1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
307 gtk_container_set_border_width(GTK_CONTAINER(v_hbox1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
308
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
309
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
310 gtk_box_pack_start(GTK_BOX(v_hbox2),love,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
311 gtk_box_pack_start(GTK_BOX(v_hbox2),skip,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
312 gtk_box_pack_start(GTK_BOX(v_hbox2),ban,TRUE,TRUE,1);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
313 gtk_box_set_spacing(GTK_BOX(v_hbox1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
314 gtk_container_set_border_width(GTK_CONTAINER(v_hbox1),2);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
315
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
316
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
317
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
318 gtk_container_add (GTK_CONTAINER (window), vboxw);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
319
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
320 g_signal_connect (G_OBJECT (love), "button_press_event",G_CALLBACK (love_press_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
321 g_signal_connect (G_OBJECT (add), "button_press_event",G_CALLBACK (add_press_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
322 g_signal_connect (G_OBJECT (ban), "button_press_event",G_CALLBACK (ban_press_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
323 g_signal_connect (G_OBJECT (skip), "button_press_event",G_CALLBACK (skip_press_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
324 g_signal_connect (G_OBJECT (neighbours), "button_press_event",G_CALLBACK (neighbours_press_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
325 g_signal_connect (G_OBJECT (personal), "button_press_event",G_CALLBACK (personal_press_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
326 g_signal_connect (G_OBJECT (window), "delete_event",G_CALLBACK (gtk_widget_hide_all), window);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
327 g_signal_connect (G_OBJECT (window), "key_press_event",G_CALLBACK(keypress_callback), NULL);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
328
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
329 gtk_widget_set_size_request(GTK_WIDGET(window),400,124);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
330 gtk_window_set_resizable(GTK_WINDOW(window),FALSE);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
331 gtk_widget_show_all(gui_window);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
332 return window;
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
333 }
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
334 #if 0
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
335 static void no_lastfm_plugin_dialog(void)
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
336 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
337 const gchar *markup =
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
338 N_("<b><big>The lastfm radio plugin could not be found.</big></b>\n\n"
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
339 "Check if the AudioScrobbler plugin was compiled in\n");
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
340
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
341 GtkWidget *dialog =
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
342 gtk_message_dialog_new_with_markup(NULL,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
343 GTK_DIALOG_DESTROY_WITH_PARENT,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
344 GTK_MESSAGE_ERROR,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
345 GTK_BUTTONS_OK,
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
346 _(markup));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
347 gtk_dialog_run(GTK_DIALOG(dialog));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
348 gtk_widget_destroy(dialog);
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
349 }
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
350 #endif
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
351
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
352
3023
49ce30748980 added lastfm GUI stub
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
353 void ui_lastfm(void)
49ce30748980 added lastfm GUI stub
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
354 {
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
355 /*if(!mowgli_global_storage_get("lastfm_loaded"))
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
356 {
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
357 no_lastfm_plugin_dialog();
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
358 return;
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
359 }
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
360 */
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
361 init_last_fm();
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
362 if(!gui_window)
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
363 {
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
364 if((gui_window = ui_lastfm_create())!=NULL);
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
365 gtk_widget_show_all(gui_window);
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
366 #if 0 /*here should be set the artist, title and album labels at the first run, because it isn't captured by the hook*/
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
367 gchar* current_title = playlist_get_songtitle(current_playlist,playlist_get_position(current_playlist));
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
368 if(current_title)
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
369 change_track_data_cb(current_title,NULL);
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
370 #endif
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
371 }
3193
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
372 else
1fef0ac7395e fixed crashes
Cristi Magherusan <majeru@atheme-project.org>
parents: 3183
diff changeset
373 gtk_widget_show_all(gui_window);
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
374
3023
49ce30748980 added lastfm GUI stub
Cristi Magherusan <majeru@atheme-project.org>
parents:
diff changeset
375 }
3183
bcf611cf5ae2 lastfm radio GUI
Cristi Magherusan <majeru@atheme-project.org>
parents: 3023
diff changeset
376