1
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
4
* Copyright (C) Philippe Rouquier 2008 <bonfire-app@wanadoo.fr>
6
* brasero is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by the
8
* Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* brasero is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
4
* Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
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.
11
* brasero is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
14
* See the GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License along
17
* with this program. If not, see <http://www.gnu.org/licenses/>.
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.
20
23
#ifdef HAVE_CONFIG_H
56
65
G_DEFINE_TYPE (BraseroProjectName, brasero_project_name, GTK_TYPE_ENTRY);
73
brasero_project_name_data_icon_error (BraseroProjectName *project,
78
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (project));
79
brasero_utils_message_dialog (toplevel,
80
/* Translators: this is a picture not
82
C_("picture", "Please select another image."),
83
error? error->message:_("Unknown error"),
88
brasero_project_name_icon_update (BraseroProjectName *self,
89
BraseroTrackDataCfg *track)
95
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self),
96
GTK_ENTRY_ICON_PRIMARY,
98
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
99
GTK_ENTRY_ICON_PRIMARY,
102
icon = brasero_track_data_cfg_get_icon_path (track);
104
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
105
GTK_ENTRY_ICON_PRIMARY,
110
/* Load and convert the image into a pixbuf */
111
pixbuf = gdk_pixbuf_new_from_file_at_scale (icon,
117
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
118
GTK_ENTRY_ICON_PRIMARY,
120
brasero_project_name_data_icon_error (self, error);
121
g_error_free (error);
125
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self),
126
GTK_ENTRY_ICON_PRIMARY,
128
g_object_unref (pixbuf);
132
brasero_project_name_icon_changed_cb (BraseroTrackDataCfg *track,
133
BraseroProjectName *self)
135
brasero_project_name_icon_update (self, track);
138
static BraseroTrackDataCfg *
139
brasero_project_name_get_track_data_cfg (BraseroProjectName *self)
141
BraseroProjectNamePrivate *priv;
144
priv = BRASERO_PROJECT_NAME_PRIVATE (self);
146
tracks = brasero_burn_session_get_tracks (priv->session);
147
for (; tracks; tracks = tracks->next) {
148
BraseroTrackDataCfg *track;
150
track = tracks->data;
151
if (BRASERO_IS_TRACK_DATA_CFG (track))
152
return BRASERO_TRACK_DATA_CFG (track);
159
brasero_project_name_icon_button_clicked (BraseroProjectName *project,
160
GtkEntryIconPosition position,
164
BraseroProjectNamePrivate *priv;
165
BraseroTrackDataCfg *track;
166
GtkFileFilter *filter;
167
const gchar *filename;
168
GError *error = NULL;
173
priv = BRASERO_PROJECT_NAME_PRIVATE (project);
175
track = brasero_project_name_get_track_data_cfg (project);
179
filename = brasero_track_data_cfg_get_icon_path (track);
181
chooser = gtk_file_chooser_dialog_new (_("Medium Icon"),
182
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (project))),
183
GTK_FILE_CHOOSER_ACTION_OPEN,
184
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
185
GTK_STOCK_OK, GTK_RESPONSE_OK,
188
filter = gtk_file_filter_new ();
189
gtk_file_filter_set_name (filter, _("All files"));
190
gtk_file_filter_add_pattern (filter, "*");
191
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
193
filter = gtk_file_filter_new ();
194
/* Translators: this is an image, a picture, not a "Disc Image" */
195
gtk_file_filter_set_name (filter, C_("picture", "Image files"));
196
gtk_file_filter_add_mime_type (filter, "image/*");
197
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter);
199
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter);
202
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (chooser), filename);
204
gtk_widget_show (chooser);
205
res = gtk_dialog_run (GTK_DIALOG (chooser));
206
if (res != GTK_RESPONSE_OK) {
207
gtk_widget_destroy (chooser);
211
path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
212
gtk_widget_destroy (chooser);
214
/* Get the BraseroTrackDataCfg if any and set the icon */
215
if (!brasero_track_data_cfg_set_icon (track, path, &error)) {
217
brasero_project_name_data_icon_error (project, error);
218
g_error_free (error);
59
225
brasero_project_name_truncate_label (const gchar *label)
229
brasero_project_name_set_type (BraseroProjectName *self,
230
BraseroProjectType type)
408
brasero_project_name_set_type (BraseroProjectName *self)
232
410
BraseroProjectNamePrivate *priv;
411
BraseroTrackType *track_type;
412
BraseroProjectType type;
233
413
gchar *title_str = NULL;
235
415
priv = BRASERO_PROJECT_NAME_PRIVATE (self);
417
track_type = brasero_track_type_new ();
418
brasero_burn_session_get_input_type (priv->session, track_type);
420
if (brasero_track_type_get_has_data (track_type))
421
type = BRASERO_PROJECT_TYPE_DATA;
422
else if (brasero_track_type_get_has_stream (track_type)) {
423
if (BRASERO_STREAM_FORMAT_HAS_VIDEO (brasero_track_type_get_stream_format (track_type)))
424
type = BRASERO_PROJECT_TYPE_VIDEO;
426
type = BRASERO_PROJECT_TYPE_AUDIO;
429
type = BRASERO_PROJECT_TYPE_INVALID;
431
brasero_track_type_free (track_type);
433
if (priv->type == type)
237
436
priv->type = type;
240
g_object_unref (priv->medium);
244
437
priv->label_modified = FALSE;
246
439
title_str = brasero_project_name_get_default_label (self);
493
brasero_project_name_session_changed (BraseroProjectName *self)
495
BraseroTrackType *type;
496
BraseroProjectNamePrivate *priv;
498
priv = BRASERO_PROJECT_NAME_PRIVATE (self);
500
type = brasero_track_type_new ();
501
brasero_burn_session_get_input_type (priv->session, type);
502
if (brasero_track_type_get_has_data (type)) {
503
BraseroTrackDataCfg *track;
505
track = brasero_project_name_get_track_data_cfg (self);
507
g_signal_connect (track,
509
G_CALLBACK (brasero_project_name_icon_changed_cb),
511
brasero_project_name_icon_update (self, track);
512
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (self),
513
GTK_ENTRY_ICON_PRIMARY,
514
_("Select an icon for the disc that will appear in file managers"));
518
gtk_entry_set_icon_from_pixbuf (GTK_ENTRY (self),
519
GTK_ENTRY_ICON_PRIMARY,
521
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (self),
522
GTK_ENTRY_ICON_PRIMARY,
524
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (self),
525
GTK_ENTRY_ICON_PRIMARY,
529
brasero_track_type_free (type);
531
brasero_project_name_set_type (self);
535
brasero_project_name_track_added (BraseroBurnSession *session,
537
BraseroProjectName *self)
539
brasero_project_name_session_changed (self);
543
brasero_project_name_track_changed (BraseroBurnSession *session,
545
BraseroProjectName *self)
547
/* It can happen that stream tracks change */
548
brasero_project_name_set_type (self);
552
brasero_project_name_track_removed (BraseroBurnSession *session,
554
guint former_position,
555
BraseroProjectName *self)
557
/* Make sure we don't remain connected */
558
if (BRASERO_IS_TRACK_DATA_CFG (track))
559
g_signal_handlers_disconnect_by_func (track,
560
brasero_project_name_icon_changed_cb,
563
brasero_project_name_session_changed (self);
567
brasero_project_name_unset_session (BraseroProjectName *project)
569
BraseroProjectNamePrivate *priv;
571
priv = BRASERO_PROJECT_NAME_PRIVATE (project);
576
g_signal_handlers_disconnect_by_func (priv->session,
577
brasero_project_name_track_added,
579
g_signal_handlers_disconnect_by_func (priv->session,
580
brasero_project_name_track_changed,
582
g_signal_handlers_disconnect_by_func (priv->session,
583
brasero_project_name_track_removed,
585
g_signal_handlers_disconnect_by_func (priv->session,
586
brasero_project_name_flags_changed,
589
g_object_unref (priv->session);
590
priv->session = NULL;
594
brasero_project_name_set_session (BraseroProjectName *project,
595
BraseroBurnSession *session)
597
BraseroProjectNamePrivate *priv;
599
priv = BRASERO_PROJECT_NAME_PRIVATE (project);
601
brasero_project_name_unset_session (project);
605
priv->session = g_object_ref (session);
606
g_signal_connect (priv->session,
608
G_CALLBACK (brasero_project_name_track_added),
610
g_signal_connect (priv->session,
612
G_CALLBACK (brasero_project_name_track_changed),
614
g_signal_connect (priv->session,
616
G_CALLBACK (brasero_project_name_track_removed),
618
g_signal_connect (priv->session,
620
G_CALLBACK (brasero_project_name_flags_changed),
623
brasero_project_name_session_changed (project);
627
brasero_project_name_set_property (GObject *object,
632
BraseroProjectNamePrivate *priv;
634
priv = BRASERO_PROJECT_NAME_PRIVATE (object);
636
switch (property_id) {
638
brasero_project_name_set_session (BRASERO_PROJECT_NAME (object),
639
g_value_get_object (value));
643
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
648
brasero_project_name_get_property (GObject *object,
653
BraseroProjectNamePrivate *priv;
655
priv = BRASERO_PROJECT_NAME_PRIVATE (object);
657
switch (property_id) {
659
g_value_set_object (value, G_OBJECT (priv->session));
663
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
304
668
brasero_project_name_finalize (GObject *object)
306
670
BraseroProjectNamePrivate *priv;
308
672
priv = BRASERO_PROJECT_NAME_PRIVATE (object);
310
g_object_unref (priv->medium);
674
brasero_project_name_unset_session (BRASERO_PROJECT_NAME (object));
314
676
G_OBJECT_CLASS (brasero_project_name_parent_class)->finalize (object);