annotate audacious/newui/newui_window.c @ 1988:c97eb02a1aab trunk

[svn] - update russian translation
author nenolod
date Tue, 21 Nov 2006 11:56:37 -0800
parents 55b05e25d4ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1957
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
1 /* Audacious
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
2 * Copyright (C) 2005-2006 Audacious team
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
3 *
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
7 * (at your option) any later version.
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
8 *
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
12 * GNU General Public License for more details.
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
13 *
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
17 * 02110-1301, USA.
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
18 */
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
19
1bab360fd6c8 [svn] - add scaffolding for newui
nenolod
parents:
diff changeset
20 #include "audacious/glade.h"
1962
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
21
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
22 #ifdef HAVE_CONFIG_H
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
23 # include "config.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
24 #endif
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
25
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
26 #include <glib.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
27 #include <glib/gi18n.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
28 #include <gtk/gtk.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
29 #include <glade/glade.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
30 #include <string.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
31 #include <stddef.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
32 #include <stdio.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
33 #include <sys/types.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
34 #include <dirent.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
35 #include <unistd.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
36 #include <errno.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
37 #include <sys/types.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
38 #include <sys/stat.h>
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
39
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
40 #include "audacious/plugin.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
41 #include "audacious/pluginenum.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
42 #include "audacious/input.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
43 #include "audacious/effect.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
44 #include "audacious/general.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
45 #include "audacious/output.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
46 #include "audacious/visualization.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
47
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
48 #include "audacious/main.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
49 #include "audacious/urldecode.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
50 #include "audacious/util.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
51 #include "audacious/dnd.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
52 #include "audacious/titlestring.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
53
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
54 #include "libaudacious/configdb.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
55
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
56 #include "audacious/playlist.h"
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
57
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
58 #include "audacious/mainwin.h"
1964
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
59 #include "audacious/ui_fileinfo.h"
1962
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
60
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
61 GtkWidget *newui_win;
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
62
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
63 void
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
64 create_newui_window(void)
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
65 {
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
66 const char *glade_file = DATA_DIR "/glade/newui.glade";
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
67 GladeXML *xml;
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
68 GtkWidget *widget;
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
69
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
70 xml = glade_xml_new_or_die(_("Stock GTK2 UI"), glade_file, NULL, NULL);
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
71
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
72 glade_xml_signal_autoconnect(xml);
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
73
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
74 newui_win = glade_xml_get_widget(xml, "newui_window");
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
75 g_object_set_data(G_OBJECT(newui_win), "glade-xml", xml);
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
76
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
77 widget = glade_xml_get_widget(xml, "newui_albumart_img");
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
78 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png");
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
79
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
80 /* build menu and toolbars */
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
81 }
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
82
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
83 void
1963
8cca76c8f5c3 [svn] - show_newui_window() implementation
nenolod
parents: 1962
diff changeset
84 show_newui_window(void)
8cca76c8f5c3 [svn] - show_newui_window() implementation
nenolod
parents: 1962
diff changeset
85 {
8cca76c8f5c3 [svn] - show_newui_window() implementation
nenolod
parents: 1962
diff changeset
86 gtk_widget_show(newui_win);
8cca76c8f5c3 [svn] - show_newui_window() implementation
nenolod
parents: 1962
diff changeset
87 }
8cca76c8f5c3 [svn] - show_newui_window() implementation
nenolod
parents: 1962
diff changeset
88
1964
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
89 static void
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
90 newui_entry_set_image(const char *text)
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
91 {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
92 GladeXML *xml = g_object_get_data(G_OBJECT(newui_win), "glade-xml");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
93 GtkWidget *widget = glade_xml_get_widget(xml, "newui_albumart_img");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
94 GdkPixbuf *pixbuf;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
95 int width, height;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
96 double aspect;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
97
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
98 if (xml == NULL || widget == NULL)
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
99 return;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
100
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
101 pixbuf = gdk_pixbuf_new_from_file(text, NULL);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
102
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
103 if (pixbuf == NULL)
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
104 return;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
105
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
106 width = gdk_pixbuf_get_width(GDK_PIXBUF(pixbuf));
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
107 height = gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf));
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
108
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
109 if(strcmp(DATA_DIR "/images/audio.png", text))
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
110 {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
111 if(width == 0)
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
112 width = 1;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
113 aspect = (double)height / (double)width;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
114 if(aspect > 1.0) {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
115 height = (int)(cfg.filepopup_pixelsize * aspect);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
116 width = cfg.filepopup_pixelsize;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
117 } else {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
118 height = cfg.filepopup_pixelsize;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
119 width = (int)(cfg.filepopup_pixelsize / aspect);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
120 }
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
121 GdkPixbuf *pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
122 g_object_unref(G_OBJECT(pixbuf));
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
123 pixbuf = pixbuf2;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
124 }
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
125
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
126 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf));
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
127 g_object_unref(G_OBJECT(pixbuf));
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
128 }
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
129
1963
8cca76c8f5c3 [svn] - show_newui_window() implementation
nenolod
parents: 1962
diff changeset
130 void
1962
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
131 newui_update_nowplaying_from_entry(PlaylistEntry *entry)
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
132 {
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
133 GladeXML *xml = g_object_get_data(G_OBJECT(newui_win), "glade-xml");
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
134 GtkWidget *widget;
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
135 gchar *tmp;
1964
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
136 static gchar *last_artwork = NULL;
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
137 gchar *fullpath;
1962
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
138
1969
55b05e25d4ef [svn] - some newui stuff (and also turn it off again, giacomo will need to look at a few things)
nenolod
parents: 1968
diff changeset
139 if (entry->tuple == NULL)
55b05e25d4ef [svn] - some newui stuff (and also turn it off again, giacomo will need to look at a few things)
nenolod
parents: 1968
diff changeset
140 return;
55b05e25d4ef [svn] - some newui stuff (and also turn it off again, giacomo will need to look at a few things)
nenolod
parents: 1968
diff changeset
141
55b05e25d4ef [svn] - some newui stuff (and also turn it off again, giacomo will need to look at a few things)
nenolod
parents: 1968
diff changeset
142 widget = glade_xml_get_widget(xml, "newui_playstatus");
55b05e25d4ef [svn] - some newui stuff (and also turn it off again, giacomo will need to look at a few things)
nenolod
parents: 1968
diff changeset
143 tmp = g_strdup_printf("<b>%s</b> from <b>%s</b> by <b>%s</b>", entry->tuple->track_name,
55b05e25d4ef [svn] - some newui stuff (and also turn it off again, giacomo will need to look at a few things)
nenolod
parents: 1968
diff changeset
144 entry->tuple->album_name, entry->tuple->performer);
1962
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
145 gtk_label_set_markup(GTK_LABEL(widget), tmp);
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
146 g_free(tmp);
1964
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
147
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
148 widget = glade_xml_get_widget(xml, "newui_label_title");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
149 gtk_label_set_text(GTK_LABEL(widget), entry->tuple->track_name);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
150
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
151 widget = glade_xml_get_widget(xml, "newui_label_artist");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
152 gtk_label_set_text(GTK_LABEL(widget), entry->tuple->performer);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
153
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
154 widget = glade_xml_get_widget(xml, "newui_label_album");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
155 gtk_label_set_text(GTK_LABEL(widget), entry->tuple->album_name);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
156
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
157 widget = glade_xml_get_widget(xml, "newui_label_genre");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
158 gtk_label_set_text(GTK_LABEL(widget), entry->tuple->genre);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
159
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
160 widget = glade_xml_get_widget(xml, "newui_label_year");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
161 tmp = g_strdup_printf("%d", entry->tuple->year);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
162 gtk_label_set_text(GTK_LABEL(widget), tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
163 g_free(tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
164
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
165 widget = glade_xml_get_widget(xml, "newui_label_tracknum");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
166 tmp = g_strdup_printf("%d", entry->tuple->track_number);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
167 gtk_label_set_text(GTK_LABEL(widget), tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
168 g_free(tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
169
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
170 widget = glade_xml_get_widget(xml, "newui_label_tracklen");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
171 tmp = g_strdup_printf("%d:%02d", entry->tuple->length / 60000, (entry->tuple->length / 1000) % 60);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
172 gtk_label_set_text(GTK_LABEL(widget), tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
173 g_free(tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
174
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
175 if (cfg.use_file_cover) {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
176 /* Use the file name */
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
177 fullpath = g_strconcat(entry->tuple->file_path, "/", entry->tuple->file_name, NULL);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
178 } else {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
179 fullpath = g_strconcat(entry->tuple->file_path, "/", NULL);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
180 }
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
181
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
182 if (!last_artwork || strcmp(last_artwork, fullpath))
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
183 {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
184 if (last_artwork != NULL)
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
185 g_free(last_artwork);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
186
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
187 last_artwork = g_strdup(fullpath);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
188
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
189 tmp = fileinfo_recursive_get_image(entry->tuple->file_path, entry->tuple->file_name, 0);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
190 if (tmp)
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
191 {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
192 newui_entry_set_image(tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
193 g_free(tmp);
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
194 } else {
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
195 newui_entry_set_image(DATA_DIR "/images/audio.png");
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
196 }
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
197 }
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
198
f027afc2ca2e [svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents: 1963
diff changeset
199 g_free(fullpath);
1962
1d93c458d79b [svn] - some code
nenolod
parents: 1957
diff changeset
200 }
1967
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
201
1968
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
202 /* ********** callbacks ********** */
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
203
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
204 void
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
205 newui_set_time(gint time, gint length)
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
206 {
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
207 GladeXML *xml = g_object_get_data(G_OBJECT(newui_win), "glade-xml");
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
208 GtkWidget *widget = glade_xml_get_widget(xml, "newui_seekbar");
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
209
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
210 gtk_range_set_range(GTK_RANGE(widget), 0, length);
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
211 gtk_range_set_value(GTK_RANGE(widget), time);
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
212 }
b5fe3edc3fac [svn] - some code for seekbar
nenolod
parents: 1967
diff changeset
213
1967
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
214 /* ********** signals ********** */
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
215
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
216 void
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
217 on_newui_shuffle_cb_realize(GtkToggleButton *button, gpointer data)
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
218 {
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
219 gtk_toggle_button_set_active(button, cfg.shuffle);
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
220 }
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
221
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
222 void
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
223 on_newui_shuffle_cb_toggled(GtkToggleButton *button, gpointer data)
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
224 {
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
225 cfg.shuffle = gtk_toggle_button_get_active(button);
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
226 mainwin_shuffle_pushed(cfg.shuffle);
00db92cf9bfe [svn] - add code for the shuffle checkbox
nenolod
parents: 1964
diff changeset
227 }