1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
1 |
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
|
2 |
/*
|
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
3 |
* Brasero
|
4 |
* Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
|
|
5 |
*
|
|
6 |
* Brasero is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; either version 2 of the License, or
|
|
9 |
* (at your option) any later version.
|
|
10 |
*
|
|
11 |
* brasero is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
14 |
* See the GNU General Public License for more details.
|
|
15 |
*
|
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with brasero. If not, write to:
|
|
18 |
* The Free Software Foundation, Inc.,
|
|
19 |
* 51 Franklin Street, Fifth Floor
|
|
20 |
* Boston, MA 02110-1301, USA.
|
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
21 |
*/
|
22 |
||
23 |
#ifdef HAVE_CONFIG_H
|
|
24 |
# include <config.h>
|
|
25 |
#endif
|
|
26 |
||
27 |
#include <string.h> |
|
28 |
||
29 |
#include <glib.h> |
|
30 |
#include <glib/gi18n-lib.h> |
|
31 |
#include <glib-object.h> |
|
32 |
||
33 |
#include <gtk/gtk.h> |
|
34 |
||
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
35 |
#include "brasero-misc.h" |
36 |
||
1.1.16
by Pedro Fragoso
Import upstream version 0.9.1 |
37 |
#include "brasero-medium.h" |
38 |
#include "brasero-volume.h" |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
39 |
|
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
40 |
#include "brasero-tags.h" |
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
41 |
#include "brasero-session.h" |
42 |
#include "brasero-track-data-cfg.h" |
|
43 |
||
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
44 |
#include "brasero-project-name.h" |
45 |
#include "brasero-project-type-chooser.h" |
|
46 |
||
47 |
typedef struct _BraseroProjectNamePrivate BraseroProjectNamePrivate; |
|
48 |
struct _BraseroProjectNamePrivate |
|
49 |
{
|
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
50 |
BraseroBurnSession *session; |
51 |
||
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
52 |
BraseroProjectType type; |
53 |
||
54 |
guint label_modified:1; |
|
55 |
};
|
|
56 |
||
57 |
#define BRASERO_PROJECT_NAME_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_PROJECT_NAME, BraseroProjectNamePrivate))
|
|
58 |
||
59 |
typedef enum { |
|
60 |
CHANGED_SIGNAL, |
|
61 |
LAST_SIGNAL
|
|
62 |
} BraseroDiscSignalType; |
|
63 |
||
64 |
static guint brasero_project_name_signals [LAST_SIGNAL] = { 0 }; |
|
65 |
||
66 |
G_DEFINE_TYPE (BraseroProjectName, brasero_project_name, GTK_TYPE_ENTRY); |
|
67 |
||
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
68 |
enum { |
69 |
PROP_0, |
|
70 |
PROP_SESSION
|
|
71 |
};
|
|
72 |
||
73 |
static void |
|
74 |
brasero_project_name_data_icon_error (BraseroProjectName *project, |
|
75 |
GError *error) |
|
76 |
{
|
|
77 |
GtkWidget *toplevel; |
|
78 |
||
79 |
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project)); |
|
80 |
brasero_utils_message_dialog (toplevel, |
|
81 |
/* Translators: this is a picture not
|
|
82 |
* a disc image */
|
|
83 |
C_("picture", "Please select another image."), |
|
84 |
error? error->message:_("Unknown error"), |
|
85 |
GTK_MESSAGE_ERROR); |
|
86 |
}
|
|
87 |
||
88 |
static void |
|
89 |
brasero_project_name_icon_update (BraseroProjectName *self, |
|
90 |
BraseroTrackDataCfg *track) |
|
91 |
{
|
|
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
92 |
GIcon *icon; |
93 |
||
94 |
icon = brasero_track_data_cfg_get_icon (track); |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
95 |
if (!icon) { |
96 |
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self), |
|
97 |
GTK_ENTRY_ICON_PRIMARY, |
|
98 |
"media-optical"); |
|
99 |
return; |
|
100 |
}
|
|
101 |
||
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
102 |
gtk_entry_set_icon_from_gicon (GTK_ENTRY (self), |
103 |
GTK_ENTRY_ICON_PRIMARY, |
|
104 |
icon); |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
105 |
|
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
106 |
g_object_unref (icon); |
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
107 |
}
|
108 |
||
109 |
static void |
|
110 |
brasero_project_name_icon_changed_cb (BraseroTrackDataCfg *track, |
|
111 |
BraseroProjectName *self) |
|
112 |
{
|
|
113 |
brasero_project_name_icon_update (self, track); |
|
114 |
}
|
|
115 |
||
116 |
static BraseroTrackDataCfg * |
|
117 |
brasero_project_name_get_track_data_cfg (BraseroProjectName *self) |
|
118 |
{
|
|
119 |
BraseroProjectNamePrivate *priv; |
|
120 |
GSList *tracks; |
|
121 |
||
122 |
priv = BRASERO_PROJECT_NAME_PRIVATE (self); |
|
123 |
||
124 |
tracks = brasero_burn_session_get_tracks (priv->session); |
|
125 |
for (; tracks; tracks = tracks->next) { |
|
126 |
BraseroTrackDataCfg *track; |
|
127 |
||
128 |
track = tracks->data; |
|
129 |
if (BRASERO_IS_TRACK_DATA_CFG (track)) |
|
130 |
return BRASERO_TRACK_DATA_CFG (track); |
|
131 |
}
|
|
132 |
||
133 |
return NULL; |
|
134 |
}
|
|
135 |
||
136 |
static void |
|
137 |
brasero_project_name_icon_button_clicked (BraseroProjectName *project, |
|
138 |
GtkEntryIconPosition position, |
|
139 |
GdkEvent *event, |
|
140 |
gpointer NULL_data) |
|
141 |
{
|
|
142 |
BraseroTrackDataCfg *track; |
|
143 |
GtkFileFilter *filter; |
|
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
144 |
gchar *filename; |
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
145 |
GError *error = NULL; |
146 |
GtkWidget *chooser; |
|
147 |
gchar *path; |
|
148 |
gint res; |
|
149 |
||
150 |
track = brasero_project_name_get_track_data_cfg (project); |
|
151 |
if (!track) |
|
152 |
return; |
|
153 |
||
154 |
chooser = gtk_file_chooser_dialog_new (_("Medium Icon"), |
|
155 |
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (project))), |
|
156 |
GTK_FILE_CHOOSER_ACTION_OPEN, |
|
157 |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
158 |
GTK_STOCK_OK, GTK_RESPONSE_OK, |
|
159 |
NULL); |
|
160 |
||
161 |
filter = gtk_file_filter_new (); |
|
162 |
gtk_file_filter_set_name (filter, _("All files")); |
|
163 |
gtk_file_filter_add_pattern (filter, "*"); |
|
164 |
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); |
|
165 |
||
166 |
filter = gtk_file_filter_new (); |
|
167 |
/* Translators: this is an image, a picture, not a "Disc Image" */
|
|
168 |
gtk_file_filter_set_name (filter, C_("picture", "Image files")); |
|
169 |
gtk_file_filter_add_mime_type (filter, "image/*"); |
|
170 |
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); |
|
171 |
||
172 |
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter); |
|
173 |
||
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
174 |
filename = brasero_track_data_cfg_get_icon_path (track); |
175 |
if (filename) { |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
176 |
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename); |
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
177 |
g_free (filename); |
178 |
}
|
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
179 |
|
180 |
gtk_widget_show (chooser); |
|
181 |
res = gtk_dialog_run (GTK_DIALOG (chooser)); |
|
182 |
if (res != GTK_RESPONSE_OK) { |
|
183 |
gtk_widget_destroy (chooser); |
|
184 |
return; |
|
185 |
}
|
|
186 |
||
187 |
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); |
|
188 |
gtk_widget_destroy (chooser); |
|
189 |
||
190 |
/* Get the BraseroTrackDataCfg if any and set the icon */
|
|
191 |
if (!brasero_track_data_cfg_set_icon (track, path, &error)) { |
|
192 |
if (error) { |
|
193 |
brasero_project_name_data_icon_error (project, error); |
|
194 |
g_error_free (error); |
|
195 |
}
|
|
196 |
}
|
|
197 |
g_free (path); |
|
198 |
}
|
|
199 |
||
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
200 |
static gchar * |
201 |
brasero_project_name_truncate_label (const gchar *label) |
|
202 |
{
|
|
203 |
const gchar *delim; |
|
204 |
gchar *next_char; |
|
205 |
||
206 |
/* find last possible character. We can't just do a tmp + 32
|
|
207 |
* since we don't know if we are at the start of a character */
|
|
208 |
delim = label; |
|
209 |
while ((next_char = g_utf8_find_next_char (delim, NULL))) { |
|
210 |
if (next_char - label > 32) |
|
211 |
break; |
|
212 |
||
213 |
delim = next_char; |
|
214 |
}
|
|
215 |
||
216 |
return g_strndup (label, delim - label); |
|
217 |
}
|
|
218 |
||
219 |
static gchar * |
|
220 |
brasero_project_name_get_default_label (BraseroProjectName *self) |
|
221 |
{
|
|
222 |
time_t t; |
|
223 |
gchar buffer [128]; |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
224 |
BraseroBurnFlag flags; |
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
225 |
gchar *title_str = NULL; |
226 |
BraseroProjectNamePrivate *priv; |
|
227 |
||
228 |
priv = BRASERO_PROJECT_NAME_PRIVATE (self); |
|
229 |
||
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
230 |
if (priv->type == BRASERO_PROJECT_TYPE_INVALID) |
231 |
return g_strdup (""); |
|
232 |
||
233 |
flags = brasero_burn_session_get_flags (priv->session); |
|
234 |
if (flags & BRASERO_BURN_FLAG_MERGE) { |
|
235 |
BraseroMedium *medium; |
|
236 |
BraseroDrive *burner; |
|
237 |
||
238 |
burner = brasero_burn_session_get_burner (priv->session); |
|
239 |
medium = brasero_drive_get_medium (burner); |
|
240 |
||
241 |
if (medium) { |
|
242 |
title_str = brasero_volume_get_name (BRASERO_VOLUME (medium)); |
|
243 |
goto end; |
|
244 |
}
|
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
245 |
}
|
246 |
||
247 |
t = time (NULL); |
|
248 |
strftime (buffer, sizeof (buffer), "%d %b %y", localtime (&t)); |
|
249 |
||
250 |
if (priv->type == BRASERO_PROJECT_TYPE_DATA) { |
|
251 |
if (!title_str || title_str [0] == '\0') { |
|
252 |
/* NOTE to translators: the final string must not be over
|
|
1.1.14
by Pedro Fragoso
Import upstream version 0.8.4 |
253 |
* 32 _bytes_ otherwise it gets truncated.
|
254 |
* The %s is the date */
|
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
255 |
title_str = g_strdup_printf (_("Data disc (%s)"), buffer); |
256 |
||
257 |
if (strlen (title_str) > 32) { |
|
258 |
g_free (title_str); |
|
259 |
strftime (buffer, sizeof (buffer), "%F", localtime (&t)); |
|
260 |
title_str = g_strdup_printf ("Data disc %s", buffer); |
|
261 |
}
|
|
262 |
}
|
|
263 |
}
|
|
264 |
else { |
|
265 |
if (priv->type == BRASERO_PROJECT_TYPE_VIDEO) |
|
266 |
/* NOTE to translators: the final string must not be over
|
|
1.1.14
by Pedro Fragoso
Import upstream version 0.8.4 |
267 |
* 32 _bytes_.
|
268 |
* The %s is the date */
|
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
269 |
title_str = g_strdup_printf (_("Video disc (%s)"), buffer); |
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
270 |
else if (priv->type == BRASERO_PROJECT_TYPE_AUDIO) { |
271 |
GSList *tracks; |
|
272 |
const gchar *album = NULL; |
|
273 |
const gchar *artist = NULL; |
|
274 |
gboolean default_album_name = TRUE; |
|
275 |
||
276 |
/* Go through all audio tracks and see if they have the
|
|
277 |
* same album and artist name. If so set the album name */
|
|
278 |
tracks = brasero_burn_session_get_tracks (priv->session); |
|
279 |
for (; tracks; tracks = tracks->next) { |
|
280 |
BraseroTrack *track; |
|
281 |
const gchar *tmp_album; |
|
282 |
const gchar *tmp_artist; |
|
283 |
||
284 |
track = tracks->data; |
|
285 |
||
286 |
tmp_album = brasero_track_tag_lookup_string (track, BRASERO_TRACK_STREAM_ALBUM_TAG); |
|
287 |
||
288 |
if (!tmp_album) { |
|
289 |
default_album_name = FALSE; |
|
290 |
break; |
|
291 |
}
|
|
292 |
||
293 |
if (album) { |
|
294 |
if (strcmp (tmp_album, album)) { |
|
295 |
default_album_name = FALSE; |
|
296 |
break; |
|
297 |
}
|
|
298 |
}
|
|
299 |
else
|
|
300 |
album = tmp_album; |
|
301 |
||
302 |
tmp_artist = brasero_track_tag_lookup_string (track, BRASERO_TRACK_STREAM_ARTIST_TAG); |
|
303 |
if (!tmp_artist) { |
|
304 |
default_album_name = FALSE; |
|
305 |
break; |
|
306 |
}
|
|
307 |
||
308 |
if (artist) { |
|
309 |
if (strcmp (tmp_artist, artist)) { |
|
310 |
default_album_name = FALSE; |
|
311 |
break; |
|
312 |
}
|
|
313 |
}
|
|
314 |
else
|
|
315 |
artist = tmp_artist; |
|
316 |
}
|
|
317 |
||
318 |
if (!artist || !album || !default_album_name) { |
|
319 |
/* NOTE to translators: the final string must not be over
|
|
320 |
* 32 _bytes_ .
|
|
321 |
* The %s is the date */
|
|
322 |
title_str = g_strdup_printf (_("Audio disc (%s)"), buffer); |
|
323 |
}
|
|
324 |
else
|
|
325 |
title_str = g_strdup (album); |
|
326 |
}
|
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
327 |
|
328 |
if (strlen (title_str) > 32) { |
|
329 |
g_free (title_str); |
|
330 |
strftime (buffer, sizeof (buffer), "%F", localtime (&t)); |
|
1.1.17
by Pedro Fragoso
Import upstream version 2.25.90 |
331 |
if (priv->type == BRASERO_PROJECT_TYPE_VIDEO) |
332 |
title_str = g_strdup_printf ("Video disc %s", buffer); |
|
333 |
else
|
|
334 |
title_str = g_strdup_printf ("Audio disc %s", buffer); |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
335 |
}
|
336 |
}
|
|
337 |
||
338 |
end: |
|
339 |
||
340 |
if (title_str && strlen (title_str) > 32) { |
|
341 |
gchar *tmp; |
|
342 |
||
343 |
tmp = brasero_project_name_truncate_label (title_str); |
|
344 |
g_free (title_str); |
|
345 |
||
346 |
title_str = tmp; |
|
347 |
}
|
|
348 |
||
349 |
return title_str; |
|
350 |
}
|
|
351 |
||
352 |
static void |
|
353 |
brasero_project_name_label_insert_text (GtkEditable *editable, |
|
354 |
const gchar *text, |
|
355 |
gint length, |
|
356 |
gint *position, |
|
357 |
gpointer NULL_data) |
|
358 |
{
|
|
359 |
const gchar *label; |
|
360 |
gchar *new_text; |
|
361 |
gint new_length; |
|
362 |
gchar *current; |
|
363 |
gint max_len; |
|
364 |
gchar *prev; |
|
365 |
gchar *next; |
|
366 |
||
367 |
/* check if this new text will fit in 32 _bytes_ long buffer */
|
|
368 |
label = gtk_entry_get_text (GTK_ENTRY (editable)); |
|
369 |
max_len = 32 - strlen (label) - length; |
|
370 |
if (max_len >= 0) |
|
371 |
return; |
|
372 |
||
373 |
gdk_beep (); |
|
374 |
||
375 |
/* get the last character '\0' of the text to be inserted */
|
|
376 |
new_length = length; |
|
377 |
new_text = g_strdup (text); |
|
378 |
current = g_utf8_offset_to_pointer (new_text, g_utf8_strlen (new_text, -1)); |
|
379 |
||
380 |
/* don't just remove one character in case there was many more
|
|
381 |
* that were inserted at the same time through DND, paste, ... */
|
|
382 |
prev = g_utf8_find_prev_char (new_text, current); |
|
383 |
if (!prev) { |
|
384 |
/* no more characters so no insertion */
|
|
385 |
g_signal_stop_emission_by_name (editable, "insert_text"); |
|
386 |
g_free (new_text); |
|
387 |
return; |
|
388 |
}
|
|
389 |
||
390 |
do { |
|
391 |
next = current; |
|
392 |
current = prev; |
|
393 |
||
394 |
prev = g_utf8_find_prev_char (new_text, current); |
|
395 |
if (!prev) { |
|
396 |
/* no more characters so no insertion */
|
|
397 |
g_signal_stop_emission_by_name (editable, "insert_text"); |
|
398 |
g_free (new_text); |
|
399 |
return; |
|
400 |
}
|
|
401 |
||
402 |
new_length -= next - current; |
|
403 |
max_len += next - current; |
|
404 |
} while (max_len < 0 && new_length > 0); |
|
405 |
||
406 |
*current = '\0'; |
|
407 |
g_signal_handlers_block_by_func (editable, |
|
408 |
(gpointer) brasero_project_name_label_insert_text, |
|
409 |
NULL_data); |
|
410 |
gtk_editable_insert_text (editable, new_text, new_length, position); |
|
411 |
g_signal_handlers_unblock_by_func (editable, |
|
412 |
(gpointer) brasero_project_name_label_insert_text, |
|
413 |
NULL_data); |
|
414 |
||
415 |
g_signal_stop_emission_by_name (editable, "insert_text"); |
|
416 |
g_free (new_text); |
|
417 |
}
|
|
418 |
||
419 |
static void |
|
420 |
brasero_project_name_label_changed (GtkEditable *editable, |
|
421 |
gpointer NULL_data) |
|
422 |
{
|
|
423 |
BraseroProjectNamePrivate *priv; |
|
424 |
||
425 |
priv = BRASERO_PROJECT_NAME_PRIVATE (editable); |
|
426 |
priv->label_modified = 1; |
|
427 |
g_signal_emit (editable, |
|
428 |
brasero_project_name_signals [CHANGED_SIGNAL], |
|
429 |
0); |
|
430 |
}
|
|
431 |
||
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
432 |
static void |
433 |
brasero_project_name_set_type (BraseroProjectName *self) |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
434 |
{
|
435 |
BraseroProjectNamePrivate *priv; |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
436 |
BraseroTrackType *track_type; |
437 |
BraseroProjectType type; |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
438 |
gchar *title_str = NULL; |
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
439 |
BraseroStatus *status; |
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
440 |
|
441 |
priv = BRASERO_PROJECT_NAME_PRIVATE (self); |
|
442 |
||
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
443 |
status = brasero_status_new (); |
444 |
brasero_burn_session_get_status (priv->session, status); |
|
1.1.36
by Martin Pitt
Import upstream version 2.29.4 |
445 |
if (brasero_status_get_result (status) != BRASERO_BURN_OK) { |
446 |
g_object_unref (status); |
|
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
447 |
return; |
1.1.36
by Martin Pitt
Import upstream version 2.29.4 |
448 |
}
|
449 |
g_object_unref (status); |
|
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
450 |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
451 |
track_type = brasero_track_type_new (); |
452 |
brasero_burn_session_get_input_type (priv->session, track_type); |
|
453 |
||
454 |
if (brasero_track_type_get_has_data (track_type)) |
|
455 |
type = BRASERO_PROJECT_TYPE_DATA; |
|
456 |
else if (brasero_track_type_get_has_stream (track_type)) { |
|
457 |
if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (track_type))) |
|
458 |
type = BRASERO_PROJECT_TYPE_VIDEO; |
|
459 |
else
|
|
460 |
type = BRASERO_PROJECT_TYPE_AUDIO; |
|
461 |
}
|
|
462 |
else
|
|
463 |
type = BRASERO_PROJECT_TYPE_INVALID; |
|
464 |
||
465 |
brasero_track_type_free (track_type); |
|
466 |
||
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
467 |
/* This is not necessarily true for audio projects as those can have the
|
468 |
* name of their album set as default; so it could easily change */
|
|
469 |
if (type != BRASERO_PROJECT_TYPE_AUDIO) { |
|
470 |
if (priv->type == type) |
|
471 |
return; |
|
472 |
}
|
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
473 |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
474 |
priv->type = type; |
1.3.7
by Didier Roche
Import upstream version 2.30.2 |
475 |
if (brasero_burn_session_get_label (priv->session)) { |
476 |
priv->label_modified = TRUE; |
|
477 |
g_signal_handlers_block_by_func (self, brasero_project_name_label_changed, NULL); |
|
478 |
gtk_entry_set_text (GTK_ENTRY (self), brasero_burn_session_get_label (priv->session)); |
|
479 |
g_signal_handlers_unblock_by_func (self, brasero_project_name_label_changed, NULL); |
|
480 |
return; |
|
481 |
}
|
|
482 |
||
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
483 |
priv->label_modified = FALSE; |
484 |
title_str = brasero_project_name_get_default_label (self); |
|
485 |
||
486 |
g_signal_handlers_block_by_func (self, brasero_project_name_label_changed, NULL); |
|
487 |
gtk_entry_set_text (GTK_ENTRY (self), title_str); |
|
488 |
g_signal_handlers_unblock_by_func (self, brasero_project_name_label_changed, NULL); |
|
489 |
||
490 |
g_free (title_str); |
|
491 |
}
|
|
492 |
||
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
493 |
static void |
494 |
brasero_project_name_flags_changed (BraseroBurnSession *session, |
|
1.1.43
by Robert Ancell
Import upstream version 2.31.91 |
495 |
GParamSpec *pspec, |
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
496 |
BraseroProjectName *self) |
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
497 |
{
|
498 |
BraseroProjectNamePrivate *priv; |
|
499 |
gchar *title_str; |
|
500 |
||
501 |
priv = BRASERO_PROJECT_NAME_PRIVATE (self); |
|
502 |
||
503 |
if (priv->label_modified) |
|
504 |
return; |
|
505 |
||
506 |
title_str = brasero_project_name_get_default_label (self); |
|
507 |
||
508 |
g_signal_handlers_block_by_func (self, brasero_project_name_label_changed, NULL); |
|
509 |
gtk_entry_set_text (GTK_ENTRY (self), title_str); |
|
510 |
g_signal_handlers_unblock_by_func (self, brasero_project_name_label_changed, NULL); |
|
511 |
||
512 |
g_free (title_str); |
|
513 |
}
|
|
514 |
||
515 |
static void |
|
516 |
brasero_project_name_init (BraseroProjectName *object) |
|
517 |
{
|
|
518 |
BraseroProjectNamePrivate *priv; |
|
519 |
||
520 |
priv = BRASERO_PROJECT_NAME_PRIVATE (object); |
|
521 |
||
522 |
priv->label_modified = 0; |
|
523 |
g_signal_connect (object, |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
524 |
"icon-release", |
525 |
G_CALLBACK (brasero_project_name_icon_button_clicked), |
|
526 |
NULL); |
|
527 |
||
528 |
g_signal_connect (object, |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
529 |
"insert_text", |
530 |
G_CALLBACK (brasero_project_name_label_insert_text), |
|
531 |
NULL); |
|
532 |
g_signal_connect (object, |
|
533 |
"changed", |
|
534 |
G_CALLBACK (brasero_project_name_label_changed), |
|
535 |
NULL); |
|
536 |
}
|
|
537 |
||
538 |
static void |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
539 |
brasero_project_name_session_changed (BraseroProjectName *self) |
540 |
{
|
|
541 |
BraseroTrackType *type; |
|
542 |
BraseroProjectNamePrivate *priv; |
|
543 |
||
544 |
priv = BRASERO_PROJECT_NAME_PRIVATE (self); |
|
545 |
||
546 |
type = brasero_track_type_new (); |
|
547 |
brasero_burn_session_get_input_type (priv->session, type); |
|
548 |
if (brasero_track_type_get_has_data (type)) { |
|
549 |
BraseroTrackDataCfg *track; |
|
550 |
||
551 |
track = brasero_project_name_get_track_data_cfg (self); |
|
552 |
if (track) { |
|
553 |
g_signal_connect (track, |
|
554 |
"icon-changed", |
|
555 |
G_CALLBACK (brasero_project_name_icon_changed_cb), |
|
556 |
self); |
|
557 |
brasero_project_name_icon_update (self, track); |
|
558 |
}
|
|
559 |
}
|
|
1.1.26
by Andreas Moog
Import upstream version 2.27.5 |
560 |
else
|
561 |
gtk_entry_set_icon_from_gicon (GTK_ENTRY (self), |
|
562 |
GTK_ENTRY_ICON_PRIMARY, |
|
563 |
NULL); |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
564 |
|
565 |
brasero_track_type_free (type); |
|
566 |
||
567 |
brasero_project_name_set_type (self); |
|
568 |
}
|
|
569 |
||
570 |
static void |
|
571 |
brasero_project_name_track_added (BraseroBurnSession *session, |
|
572 |
BraseroTrack *track, |
|
573 |
BraseroProjectName *self) |
|
574 |
{
|
|
575 |
brasero_project_name_session_changed (self); |
|
576 |
}
|
|
577 |
||
578 |
static void |
|
579 |
brasero_project_name_track_changed (BraseroBurnSession *session, |
|
580 |
BraseroTrack *track, |
|
581 |
BraseroProjectName *self) |
|
582 |
{
|
|
583 |
/* It can happen that stream tracks change */
|
|
584 |
brasero_project_name_set_type (self); |
|
585 |
}
|
|
586 |
||
587 |
static void |
|
588 |
brasero_project_name_track_removed (BraseroBurnSession *session, |
|
589 |
BraseroTrack *track, |
|
590 |
guint former_position, |
|
591 |
BraseroProjectName *self) |
|
592 |
{
|
|
593 |
/* Make sure we don't remain connected */
|
|
594 |
if (BRASERO_IS_TRACK_DATA_CFG (track)) |
|
595 |
g_signal_handlers_disconnect_by_func (track, |
|
596 |
brasero_project_name_icon_changed_cb, |
|
597 |
self); |
|
598 |
||
599 |
brasero_project_name_session_changed (self); |
|
600 |
}
|
|
601 |
||
602 |
static void |
|
603 |
brasero_project_name_unset_session (BraseroProjectName *project) |
|
604 |
{
|
|
605 |
BraseroProjectNamePrivate *priv; |
|
606 |
||
607 |
priv = BRASERO_PROJECT_NAME_PRIVATE (project); |
|
608 |
||
609 |
if (!priv->session) |
|
610 |
return; |
|
611 |
||
612 |
g_signal_handlers_disconnect_by_func (priv->session, |
|
613 |
brasero_project_name_track_added, |
|
614 |
project); |
|
615 |
g_signal_handlers_disconnect_by_func (priv->session, |
|
616 |
brasero_project_name_track_changed, |
|
617 |
project); |
|
618 |
g_signal_handlers_disconnect_by_func (priv->session, |
|
619 |
brasero_project_name_track_removed, |
|
620 |
project); |
|
621 |
g_signal_handlers_disconnect_by_func (priv->session, |
|
622 |
brasero_project_name_flags_changed, |
|
623 |
project); |
|
624 |
||
625 |
g_object_unref (priv->session); |
|
626 |
priv->session = NULL; |
|
627 |
}
|
|
628 |
||
629 |
void
|
|
630 |
brasero_project_name_set_session (BraseroProjectName *project, |
|
631 |
BraseroBurnSession *session) |
|
632 |
{
|
|
633 |
BraseroProjectNamePrivate *priv; |
|
634 |
||
635 |
priv = BRASERO_PROJECT_NAME_PRIVATE (project); |
|
636 |
||
637 |
brasero_project_name_unset_session (project); |
|
638 |
if (!session) |
|
639 |
return; |
|
640 |
||
641 |
priv->session = g_object_ref (session); |
|
1.1.35
by Robert Ancell
Import upstream version 2.29.3 |
642 |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
643 |
g_signal_connect (priv->session, |
644 |
"track-added", |
|
645 |
G_CALLBACK (brasero_project_name_track_added), |
|
646 |
project); |
|
647 |
g_signal_connect (priv->session, |
|
648 |
"track-changed", |
|
649 |
G_CALLBACK (brasero_project_name_track_changed), |
|
650 |
project); |
|
651 |
g_signal_connect (priv->session, |
|
652 |
"track-removed", |
|
653 |
G_CALLBACK (brasero_project_name_track_removed), |
|
654 |
project); |
|
655 |
g_signal_connect (priv->session, |
|
1.1.43
by Robert Ancell
Import upstream version 2.31.91 |
656 |
"notify::flags", |
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
657 |
G_CALLBACK (brasero_project_name_flags_changed), |
658 |
project); |
|
659 |
||
660 |
brasero_project_name_session_changed (project); |
|
661 |
}
|
|
662 |
||
663 |
static void |
|
664 |
brasero_project_name_set_property (GObject *object, |
|
665 |
guint property_id, |
|
666 |
const GValue *value, |
|
667 |
GParamSpec *pspec) |
|
668 |
{
|
|
669 |
switch (property_id) { |
|
670 |
case PROP_SESSION: |
|
671 |
brasero_project_name_set_session (BRASERO_PROJECT_NAME (object), |
|
672 |
g_value_get_object (value)); |
|
673 |
break; |
|
674 |
||
675 |
default: |
|
676 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
|
677 |
}
|
|
678 |
}
|
|
679 |
||
680 |
static void |
|
681 |
brasero_project_name_get_property (GObject *object, |
|
682 |
guint property_id, |
|
683 |
GValue *value, |
|
684 |
GParamSpec *pspec) |
|
685 |
{
|
|
686 |
BraseroProjectNamePrivate *priv; |
|
687 |
||
688 |
priv = BRASERO_PROJECT_NAME_PRIVATE (object); |
|
689 |
||
690 |
switch (property_id) { |
|
691 |
case PROP_SESSION: |
|
692 |
g_value_set_object (value, G_OBJECT (priv->session)); |
|
693 |
break; |
|
694 |
||
695 |
default: |
|
696 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); |
|
697 |
}
|
|
698 |
}
|
|
699 |
||
700 |
static void |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
701 |
brasero_project_name_finalize (GObject *object) |
702 |
{
|
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
703 |
brasero_project_name_unset_session (BRASERO_PROJECT_NAME (object)); |
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
704 |
|
705 |
G_OBJECT_CLASS (brasero_project_name_parent_class)->finalize (object); |
|
706 |
}
|
|
707 |
||
708 |
static void |
|
709 |
brasero_project_name_class_init (BraseroProjectNameClass *klass) |
|
710 |
{
|
|
711 |
GObjectClass* object_class = G_OBJECT_CLASS (klass); |
|
712 |
||
713 |
g_type_class_add_private (klass, sizeof (BraseroProjectNamePrivate)); |
|
714 |
||
715 |
object_class->finalize = brasero_project_name_finalize; |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
716 |
object_class->set_property = brasero_project_name_set_property; |
717 |
object_class->get_property = brasero_project_name_get_property; |
|
718 |
||
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
719 |
brasero_project_name_signals [CHANGED_SIGNAL] = |
720 |
g_signal_new ("name_changed", |
|
721 |
BRASERO_TYPE_PROJECT_NAME, |
|
722 |
G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION|G_SIGNAL_NO_RECURSE, |
|
723 |
0, |
|
724 |
NULL, |
|
725 |
NULL, |
|
726 |
g_cclosure_marshal_VOID__VOID, |
|
727 |
G_TYPE_NONE, |
|
728 |
0); |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
729 |
|
730 |
g_object_class_install_property (object_class, |
|
731 |
PROP_SESSION, |
|
732 |
g_param_spec_object ("session", |
|
733 |
"The session", |
|
734 |
"The session to work with", |
|
735 |
BRASERO_TYPE_BURN_SESSION, |
|
736 |
G_PARAM_READWRITE)); |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
737 |
}
|
738 |
||
739 |
GtkWidget * |
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
740 |
brasero_project_name_new (BraseroBurnSession *session) |
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
741 |
{
|
1.1.25
by Robert Ancell
Import upstream version 2.27.4 |
742 |
return g_object_new (BRASERO_TYPE_PROJECT_NAME, |
743 |
"session", session, |
|
744 |
NULL); |
|
1.1.13
by Pedro Fragoso
Import upstream version 0.8.3 |
745 |
}
|
746 |