~mfisch/brasero/update-to-3.8.0

« back to all changes in this revision

Viewing changes to libbrasero-burn/brasero-data-options.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-07-14 14:13:00 UTC
  • mfrom: (1.1.25 upstream)
  • Revision ID: james.westby@ubuntu.com-20090714141300-e08q13sp48b2xzwd
Tags: 2.27.4-0ubuntu1
* New upstream release: (LP: #399112)
  - Hal support removed, now relies on GIO only for drives/media probing
  - New layout for size reporting in data/audio/video project
  - Lot's of bug fixes
  - Fixed some memleaks
  - Bump libbrasero-media version to reflect changes (important to packagers)
  - Fix #582261 – brasero shows 0% done, while continues burning disc
  - Fix #582513 – Bogus VIDEO_TS directory error if AUDIO_TS directory present
  - Fix #573805 – "Increase compatibility with Windows systems"?
  - Fix #585190 – remove 0 from 03 % status
  - Fix #586744 – Use AS_HELP_STRING for configure switches
  - Fix #584793 – Poor language in warning dialog when attempting to burn an audio CD onto a CDRW
  - Fix #580617 – Brasero floods .xsession-errors log with "Unknown (or already deleted) monitored directory" warnings
  - Fix #563501 – Brasero burning window shouldn't try to show drive speed while is converting audio files
  - Fix #485719 – Burn dialog CD icon
  - Fix #585481 – Deep hierarchy warning
  - Fix #554070 – The need of a "replace all" and "replace non" button
  - Fix #582461 – Brasero hangs at normalizing tracks
  - Fix #587284 – nautilus hangs every time
  - Fix #574093 – Caret visible in instructions for project creation
  - Fix #581742 – port from HAL to DeviceKit-disks
  - Fix #573801 – Bad error message when burning empty burn:///
  - Fix #573486 – Various i18n and string issues for good
  - Fix #587399 – License clarification
  - Fix #587554 – Unclear meaning of text
  - Fix #582979 – brasero should not include Categories in mime handler .desktop files
  - Fix #586040 – duplicated command listed in open-with dialog
  - Fixes for #573486 – Various i18n and string issues
* debian/control.in:
  - Add in missing comma in brasero suggests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
 
/*
3
 
 * Libbrasero-burn
4
 
 * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
5
 
 *
6
 
 * Libbrasero-burn 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
 
 * The Libbrasero-burn authors hereby grant permission for non-GPL compatible
12
 
 * GStreamer plugins to be used and distributed together with GStreamer
13
 
 * and Libbrasero-burn. This permission is above and beyond the permissions granted
14
 
 * by the GPL license by which Libbrasero-burn is covered. If you modify this code
15
 
 * you may extend this exception to your version of the code, but you are not
16
 
 * obligated to do so. If you do not wish to do so, delete this exception
17
 
 * statement from your version.
18
 
 * 
19
 
 * Libbrasero-burn is distributed in the hope that it will be useful,
20
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 
 * GNU Library General Public License for more details.
23
 
 * 
24
 
 * You should have received a copy of the GNU General Public License
25
 
 * along with this program; if not, write to:
26
 
 *      The Free Software Foundation, Inc.,
27
 
 *      51 Franklin Street, Fifth Floor
28
 
 *      Boston, MA  02110-1301, USA.
29
 
 */
30
 
 
31
 
#ifdef HAVE_CONFIG_H
32
 
#  include <config.h>
33
 
#endif
34
 
 
35
 
#include <glib.h>
36
 
#include <glib/gi18n-lib.h>
37
 
#include <glib-object.h>
38
 
 
39
 
#include <gtk/gtk.h>
40
 
 
41
 
#include "brasero-misc.h"
42
 
#include "brasero-track-data.h"
43
 
#include "brasero-session.h"
44
 
#include "brasero-data-options.h"
45
 
 
46
 
typedef struct _BraseroDataOptionsPrivate BraseroDataOptionsPrivate;
47
 
struct _BraseroDataOptionsPrivate
48
 
{
49
 
        BraseroBurnSession *session;
50
 
 
51
 
        GtkWidget *joliet_toggle;
52
 
 
53
 
        guint joliet_warning:1;
54
 
        guint joliet_saved:1;
55
 
};
56
 
 
57
 
/* FIXME: we need to react to a valid signal so that if joliet is on and the
58
 
 * session is invalid we can try to see if deactivating it can make things
59
 
 * workable again. */
60
 
 
61
 
#define BRASERO_DATA_OPTIONS_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DATA_OPTIONS, BraseroDataOptionsPrivate))
62
 
 
63
 
enum {
64
 
        PROP_0,
65
 
        PROP_SESSION
66
 
};
67
 
 
68
 
G_DEFINE_TYPE (BraseroDataOptions, brasero_data_options, GTK_TYPE_ALIGNMENT);
69
 
 
70
 
static void
71
 
brasero_data_options_set_tracks_image_fs (BraseroBurnSession *session,
72
 
                                          BraseroImageFS fs_type_add,
73
 
                                          BraseroImageFS fs_type_rm)
74
 
{
75
 
        GSList *tracks;
76
 
        GSList *iter;
77
 
 
78
 
        tracks = brasero_burn_session_get_tracks (session);
79
 
        for (iter = tracks; iter; iter = iter->next) {
80
 
                BraseroTrack *track;
81
 
 
82
 
                track = iter->data;
83
 
                if (!BRASERO_IS_TRACK_DATA (track))
84
 
                        continue;
85
 
 
86
 
                if (fs_type_add != BRASERO_IMAGE_FS_NONE)
87
 
                        brasero_track_data_add_fs (BRASERO_TRACK_DATA (track), fs_type_add);
88
 
 
89
 
                if (fs_type_rm != BRASERO_IMAGE_FS_NONE)
90
 
                        brasero_track_data_rm_fs (BRASERO_TRACK_DATA (track), fs_type_rm);
91
 
        }
92
 
}
93
 
 
94
 
static void
95
 
brasero_data_options_set_joliet (BraseroDataOptions *dialog)
96
 
{
97
 
        BraseroDataOptionsPrivate *priv;
98
 
        BraseroTrackType *source = NULL;
99
 
 
100
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (dialog);
101
 
 
102
 
        if (!priv->joliet_toggle)
103
 
                return;
104
 
 
105
 
        /* NOTE: we don't check for the sensitive property since when
106
 
         * something is compulsory the button is active but insensitive */
107
 
        source = brasero_track_type_new ();
108
 
        if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->joliet_toggle)))
109
 
                brasero_data_options_set_tracks_image_fs (priv->session,
110
 
                                                          BRASERO_IMAGE_FS_NONE,
111
 
                                                          BRASERO_IMAGE_FS_JOLIET);
112
 
        else
113
 
                brasero_data_options_set_tracks_image_fs (priv->session,
114
 
                                                          BRASERO_IMAGE_FS_JOLIET,
115
 
                                                          BRASERO_IMAGE_FS_NONE);
116
 
 
117
 
        brasero_track_type_free (source);
118
 
}
119
 
 
120
 
static void
121
 
brasero_data_options_joliet_toggled_cb (GtkToggleButton *toggle,
122
 
                                        BraseroDataOptions *options)
123
 
{
124
 
        BraseroDataOptionsPrivate *priv;
125
 
        GtkResponseType answer;
126
 
        GtkWidget *message;
127
 
        gchar *secondary;
128
 
 
129
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (options);
130
 
 
131
 
        /* If the toggle button was active it means that either the user got the
132
 
         * warning dialog or that it was on because no file required any change
133
 
         * in their names so no need for the warning; especially when we turn it
134
 
         * off. */
135
 
        if (!gtk_toggle_button_get_active (toggle))
136
 
                priv->joliet_warning = TRUE;
137
 
 
138
 
        if (priv->joliet_warning) {
139
 
                brasero_data_options_set_joliet (options);
140
 
                return;
141
 
        }
142
 
 
143
 
        message = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (options))),
144
 
                                          GTK_DIALOG_DESTROY_WITH_PARENT|
145
 
                                          GTK_DIALOG_MODAL,
146
 
                                          GTK_MESSAGE_INFO,
147
 
                                          GTK_BUTTONS_NONE,
148
 
                                          _("Should files be renamed to be fully Windows-compatible?"));
149
 
 
150
 
        secondary = g_strdup_printf ("%s\n%s",
151
 
                                     _("Some files don't have a suitable name for a fully Windows-compatible CD."),
152
 
                                     _("Those names should be changed and truncated to 64 characters."));
153
 
        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s", secondary);
154
 
        g_free (secondary);
155
 
 
156
 
        gtk_dialog_add_button (GTK_DIALOG (message),
157
 
                               _("_Disable Full Windows Compatibility"),
158
 
                               GTK_RESPONSE_CANCEL);
159
 
        gtk_dialog_add_button (GTK_DIALOG (message),
160
 
                               _("_Rename for Full Windows Compatibility"),
161
 
                               GTK_RESPONSE_YES);
162
 
 
163
 
        answer = gtk_dialog_run (GTK_DIALOG (message));
164
 
        gtk_widget_destroy (message);
165
 
 
166
 
        if (answer != GTK_RESPONSE_YES)
167
 
                gtk_toggle_button_set_active (toggle, FALSE);
168
 
        else
169
 
                brasero_data_options_set_joliet (options);
170
 
 
171
 
        priv->joliet_warning = TRUE;
172
 
}
173
 
 
174
 
#if 0
175
 
 
176
 
static gboolean
177
 
brasero_data_options_update_joliet (BraseroDataOptions *dialog)
178
 
{
179
 
        BraseroImageFS fs_type;
180
 
        BraseroBurnResult result;
181
 
        BraseroTrackType *source = NULL;
182
 
        BraseroDataOptionsPrivate *priv;
183
 
 
184
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (dialog);
185
 
        if (!priv->joliet_toggle)
186
 
                return FALSE;
187
 
 
188
 
        /* what we want to check Joliet support */
189
 
        source = brasero_track_type_new ();
190
 
        brasero_burn_session_get_input_type (priv->session, source);
191
 
        fs_type = brasero_track_type_get_data_fs (source);
192
 
 
193
 
        /* see if it's supported */
194
 
        brasero_track_type_set_data_fs (source,
195
 
                                        fs_type|
196
 
                                        BRASERO_IMAGE_FS_JOLIET);
197
 
 
198
 
        result = brasero_burn_session_input_supported (priv->session,
199
 
                                                       source,
200
 
                                                       FALSE);
201
 
 
202
 
        if (result != BRASERO_BURN_OK) {
203
 
                /* Not supported */
204
 
                priv->joliet_saved = (fs_type & BRASERO_IMAGE_FS_JOLIET);
205
 
                brasero_data_options_set_tracks_image_fs (priv->session,
206
 
                                                          BRASERO_IMAGE_FS_NONE,
207
 
                                                          BRASERO_IMAGE_FS_JOLIET);
208
 
 
209
 
                gtk_widget_set_sensitive (priv->joliet_toggle, FALSE);
210
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->joliet_toggle), FALSE);
211
 
        }
212
 
        else if (!GTK_WIDGET_IS_SENSITIVE (priv->joliet_toggle)) {
213
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->joliet_toggle), priv->joliet_saved);
214
 
 
215
 
                if (priv->joliet_saved || (fs_type & BRASERO_IMAGE_FS_JOLIET))
216
 
                        brasero_data_options_set_tracks_image_fs (priv->session,
217
 
                                                                  BRASERO_IMAGE_FS_JOLIET,
218
 
                                                                  BRASERO_IMAGE_FS_NONE);
219
 
 
220
 
                gtk_widget_set_sensitive (priv->joliet_toggle, TRUE);
221
 
        }
222
 
}
223
 
 
224
 
#endif
225
 
 
226
 
static void
227
 
brasero_data_options_update_joliet_start (BraseroDataOptions *dialog)
228
 
{
229
 
        BraseroImageFS fs_type;
230
 
        BraseroBurnResult result;
231
 
        BraseroTrackType *source = NULL;
232
 
        BraseroDataOptionsPrivate *priv;
233
 
 
234
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (dialog);
235
 
        if (!priv->joliet_toggle)
236
 
                return;
237
 
 
238
 
        /* what we want to check Joliet support */
239
 
        source = brasero_track_type_new ();
240
 
        brasero_burn_session_get_input_type (priv->session, source);
241
 
        fs_type = brasero_track_type_get_data_fs (source);
242
 
 
243
 
        brasero_track_type_set_data_fs (source,
244
 
                                        fs_type|
245
 
                                        BRASERO_IMAGE_FS_JOLIET);
246
 
        result = brasero_burn_session_input_supported (priv->session,
247
 
                                                       source,
248
 
                                                       FALSE);
249
 
 
250
 
        g_signal_handlers_block_by_func (priv->joliet_toggle,
251
 
                                         brasero_data_options_joliet_toggled_cb,
252
 
                                         dialog);
253
 
 
254
 
        if (result != BRASERO_BURN_OK) {
255
 
                /* Not supported */
256
 
                brasero_data_options_set_tracks_image_fs (priv->session,
257
 
                                                          BRASERO_IMAGE_FS_NONE,
258
 
                                                          BRASERO_IMAGE_FS_JOLIET);
259
 
 
260
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->joliet_toggle), FALSE);
261
 
                gtk_widget_set_sensitive (priv->joliet_toggle, FALSE);
262
 
        }
263
 
        else {
264
 
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->joliet_toggle),
265
 
                                              (fs_type & BRASERO_IMAGE_FS_JOLIET));
266
 
                gtk_widget_set_sensitive (priv->joliet_toggle, TRUE);
267
 
        }
268
 
 
269
 
        g_signal_handlers_unblock_by_func (priv->joliet_toggle,
270
 
                                           brasero_data_options_joliet_toggled_cb,
271
 
                                           dialog);
272
 
}
273
 
 
274
 
static void
275
 
brasero_data_options_set_property (GObject *object,
276
 
                                   guint prop_id,
277
 
                                   const GValue *value,
278
 
                                   GParamSpec *pspec)
279
 
{
280
 
        BraseroDataOptionsPrivate *priv;
281
 
 
282
 
        g_return_if_fail (BRASERO_IS_DATA_OPTIONS (object));
283
 
 
284
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (object);
285
 
 
286
 
        switch (prop_id)
287
 
        {
288
 
        case PROP_SESSION: /* Readable and only writable at creation time */
289
 
                priv->session = BRASERO_BURN_SESSION (g_value_get_object (value));
290
 
                g_object_ref (priv->session);
291
 
                brasero_data_options_update_joliet_start (BRASERO_DATA_OPTIONS (object));
292
 
                break;
293
 
        default:
294
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
295
 
                break;
296
 
        }
297
 
}
298
 
 
299
 
static void
300
 
brasero_data_options_get_property (GObject *object,
301
 
                                   guint prop_id,
302
 
                                   GValue *value,
303
 
                                   GParamSpec *pspec)
304
 
{
305
 
        BraseroDataOptionsPrivate *priv;
306
 
 
307
 
        g_return_if_fail (BRASERO_IS_DATA_OPTIONS (object));
308
 
 
309
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (object);
310
 
 
311
 
        switch (prop_id)
312
 
        {
313
 
        case PROP_SESSION:
314
 
                g_value_set_object (value, priv->session);
315
 
                g_object_ref (priv->session);
316
 
                break;
317
 
        default:
318
 
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
319
 
                break;
320
 
        }
321
 
}
322
 
 
323
 
static void
324
 
brasero_data_options_init (BraseroDataOptions *object)
325
 
{
326
 
        BraseroDataOptionsPrivate *priv;
327
 
        GtkWidget *options;
328
 
        gchar *string;
329
 
 
330
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (object);
331
 
 
332
 
        /* general options */
333
 
        priv->joliet_toggle = gtk_check_button_new_with_mnemonic (_("Increase compatibility with _Windows systems"));
334
 
        gtk_widget_set_tooltip_text (priv->joliet_toggle,
335
 
                                     _("Improve compatibility with Windows systems by allowing to display long filenames (maximum 64 characters)"));
336
 
 
337
 
        g_signal_connect (priv->joliet_toggle,
338
 
                          "toggled",
339
 
                          G_CALLBACK (brasero_data_options_joliet_toggled_cb),
340
 
                          object);
341
 
 
342
 
        string = g_strdup_printf ("<b>%s</b>", _("Disc options"));
343
 
        options = brasero_utils_pack_properties (string,
344
 
                                                 priv->joliet_toggle,
345
 
                                                 NULL);
346
 
        g_free (string);
347
 
 
348
 
        gtk_widget_show_all (options);
349
 
        gtk_container_add (GTK_CONTAINER (object), options);
350
 
}
351
 
 
352
 
static void
353
 
brasero_data_options_finalize (GObject *object)
354
 
{
355
 
        BraseroDataOptionsPrivate *priv;
356
 
 
357
 
        priv = BRASERO_DATA_OPTIONS_PRIVATE (object);
358
 
        if (priv->session) {
359
 
                g_object_unref (priv->session);
360
 
                priv->session = NULL;
361
 
        }
362
 
 
363
 
        G_OBJECT_CLASS (brasero_data_options_parent_class)->finalize (object);
364
 
}
365
 
 
366
 
static void
367
 
brasero_data_options_class_init (BraseroDataOptionsClass *klass)
368
 
{
369
 
        GObjectClass* object_class = G_OBJECT_CLASS (klass);
370
 
 
371
 
        g_type_class_add_private (klass, sizeof (BraseroDataOptionsPrivate));
372
 
 
373
 
        object_class->finalize = brasero_data_options_finalize;
374
 
        object_class->set_property = brasero_data_options_set_property;
375
 
        object_class->get_property = brasero_data_options_get_property;
376
 
 
377
 
        g_object_class_install_property (object_class,
378
 
                                         PROP_SESSION,
379
 
                                         g_param_spec_object ("session",
380
 
                                                              "The session",
381
 
                                                              "The session to work with",
382
 
                                                              BRASERO_TYPE_BURN_SESSION,
383
 
                                                              G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
384
 
}
385
 
 
386
 
GtkWidget *
387
 
brasero_data_options_new (BraseroBurnSession *session)
388
 
{
389
 
        return g_object_new (BRASERO_TYPE_DATA_OPTIONS, "session", session, NULL);
390
 
}
391