~ubuntu-branches/ubuntu/trusty/sound-juicer/trusty

« back to all changes in this revision

Viewing changes to src/sj-main.c

  • Committer: Bazaar Package Importer
  • Author(s): Bilal Akhtar
  • Date: 2010-08-20 14:02:25 UTC
  • mfrom: (1.1.44 upstream)
  • Revision ID: james.westby@ubuntu.com-20100820140225-cj8w9u6uj4ml19or
Tags: 2.31.6-0ubuntu1
New upstream release. (LP: #621065)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <gdk/gdkkeysyms.h>
31
31
#include <gio/gio.h>
32
32
#include <gtk/gtk.h>
33
 
#include <glade/glade.h>
34
33
#include <gconf/gconf-client.h>
35
34
#include <brasero-medium-selection.h>
36
35
#include <brasero-volume.h>
49
48
#include "sj-prefs.h"
50
49
#include "sj-play.h"
51
50
#include "sj-genres.h"
52
 
#include "gedit-message-area.h"
53
51
 
54
52
gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data);
55
53
 
58
56
static void set_duplication (gboolean enable);
59
57
 
60
58
/* Prototypes for the signal blocking/unblocking in update_ui_for_album */
61
 
void on_title_edit_changed(GtkEditable *widget, gpointer user_data);
62
 
void on_artist_edit_changed(GtkEditable *widget, gpointer user_data);
63
 
void on_year_edit_changed(GtkEditable *widget, gpointer user_data);
64
 
void on_disc_number_edit_changed(GtkEditable *widget, gpointer user_data);
 
59
G_MODULE_EXPORT void on_title_edit_changed(GtkEditable *widget, gpointer user_data);
 
60
G_MODULE_EXPORT void on_artist_edit_changed(GtkEditable *widget, gpointer user_data);
 
61
G_MODULE_EXPORT void on_year_edit_changed(GtkEditable *widget, gpointer user_data);
 
62
G_MODULE_EXPORT void on_disc_number_edit_changed(GtkEditable *widget, gpointer user_data);
65
63
 
66
 
GladeXML *glade;
 
64
GtkBuilder *builder;
67
65
 
68
66
SjMetadataGetter *metadata;
69
67
SjExtractor *extractor;
104
102
 
105
103
#define DEFAULT_PARANOIA 4
106
104
#define RAISE_WINDOW "raise-window"
107
 
#define SOURCE_GLADE "../data/sound-juicer.glade"
108
 
#define INSTALLED_GLADE DATADIR"/sound-juicer/sound-juicer.glade"
 
105
#define SOURCE_BUILDER "../data/sound-juicer.ui"
 
106
#define INSTALLED_BUILDER DATADIR"/sound-juicer/sound-juicer.ui"
109
107
 
110
108
void
111
109
sj_stock_init (void)
177
175
static void error_on_start (GError *error)
178
176
{
179
177
  GtkWidget *dialog;
180
 
  dialog = gtk_message_dialog_new (NULL, 0,
181
 
                                   GTK_MESSAGE_ERROR,
182
 
                                   GTK_BUTTONS_CLOSE,
183
 
                                   "<b>%s</b>\n\n%s: %s.\n%s",
184
 
                                   _("Could not start Sound Juicer"),
185
 
                                   _("Reason"),
186
 
                                   error->message,
187
 
                                   _("Please consult the documentation for assistance."));
188
 
  gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
 
178
  dialog = gtk_message_dialog_new_with_markup (NULL, 0,
 
179
                                               GTK_MESSAGE_ERROR,
 
180
                                               GTK_BUTTONS_CLOSE,
 
181
                                               "<b>%s</b>\n\n%s: %s.\n%s",
 
182
                                               _("Could not start Sound Juicer"),
 
183
                                               _("Reason"),
 
184
                                               error->message,
 
185
                                               _("Please consult the documentation for assistance."));
189
186
  gtk_dialog_run (GTK_DIALOG (dialog));
190
187
}
191
188
 
192
189
/**
193
190
 * Clicked Quit
194
191
 */
195
 
void on_quit_activate (GtkMenuItem *item, gpointer user_data)
 
192
G_MODULE_EXPORT void on_quit_activate (GtkMenuItem *item, gpointer user_data)
196
193
{
197
194
  if (on_delete_event (NULL, NULL, NULL) == FALSE) {
198
195
    gtk_main_quit ();
202
199
/**
203
200
 * Destroy signal Callback
204
201
 */
205
 
void on_destroy_signal (GtkMenuItem *item, gpointer user_data)
 
202
G_MODULE_EXPORT void on_destroy_signal (GtkMenuItem *item, gpointer user_data)
206
203
{
207
204
   gtk_main_quit ();
208
205
}
210
207
/**
211
208
 * Clicked Eject
212
209
 */
213
 
void on_eject_activate (GtkMenuItem *item, gpointer user_data)
 
210
G_MODULE_EXPORT void on_eject_activate (GtkMenuItem *item, gpointer user_data)
214
211
{
215
212
  /* first make sure we're not playing */
216
213
  stop_playback ();
218
215
  brasero_drive_eject (drive, FALSE, NULL);
219
216
}
220
217
 
221
 
gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
 
218
G_MODULE_EXPORT gboolean on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data)
222
219
{
223
220
  if (extracting) {
224
221
    GtkWidget *dialog;
251
248
  return FALSE;
252
249
}
253
250
 
254
 
void on_select_all_activate (GtkMenuItem *item, gpointer user_data)
 
251
G_MODULE_EXPORT void on_select_all_activate (GtkMenuItem *item, gpointer user_data)
255
252
{
256
253
  gtk_tree_model_foreach (GTK_TREE_MODEL (track_store), select_all_foreach_cb, GINT_TO_POINTER (TRUE));
257
254
  gtk_widget_set_sensitive (extract_button, TRUE);
261
258
  no_of_tracks_selected = total_no_of_tracks;
262
259
}
263
260
 
264
 
void on_deselect_all_activate (GtkMenuItem *item, gpointer user_data)
 
261
G_MODULE_EXPORT void on_deselect_all_activate (GtkMenuItem *item, gpointer user_data)
265
262
{
266
263
  gtk_tree_model_foreach (GTK_TREE_MODEL (track_store), select_all_foreach_cb, GINT_TO_POINTER (FALSE));
267
264
  gtk_widget_set_sensitive (extract_button, FALSE);
321
318
 
322
319
/* Taken from gedit */
323
320
static void
324
 
set_message_area_text_and_icon (GeditMessageArea *message_area,
325
 
                                const gchar   *icon_stock_id,
326
 
                                const gchar   *primary_text,
327
 
                                const gchar   *secondary_text,
328
 
                                GtkWidget *button)
 
321
set_info_bar_text_and_icon (GtkInfoBar  *infobar,
 
322
                            const gchar *icon_stock_id,
 
323
                            const gchar *primary_text,
 
324
                            const gchar *secondary_text,
 
325
                            GtkWidget   *button)
329
326
{
 
327
  GtkWidget *content_area;
330
328
  GtkWidget *hbox_content;
331
329
  GtkWidget *image;
332
330
  GtkWidget *vbox;
377
375
                                 gtk_widget_get_accessible (secondary_label));
378
376
  }
379
377
 
380
 
  gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (message_area),
381
 
                                   hbox_content);
 
378
  content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar));
 
379
  gtk_container_add (GTK_CONTAINER (content_area), hbox_content);
382
380
}
383
381
 
384
382
/* Taken from gedit */
404
402
}
405
403
 
406
404
static GtkWidget*
407
 
musicbrainz_submit_message_area_new (char *title, char *artist)
 
405
musicbrainz_submit_info_bar_new (char *title, char *artist)
408
406
{
409
 
  GtkWidget *message_area, *button;
 
407
  GtkWidget *infobar, *button;
410
408
  char *primary_text;
411
409
 
412
410
  g_return_val_if_fail (title != NULL, NULL);
413
411
  g_return_val_if_fail (artist != NULL, NULL);
414
412
 
415
 
  message_area = gedit_message_area_new ();
416
 
 
417
 
  button = gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
418
 
                                          _("S_ubmit Album"),
419
 
                                          GTK_RESPONSE_OK);
420
 
  gedit_message_area_add_button (GEDIT_MESSAGE_AREA (message_area),
421
 
                                 GTK_STOCK_CANCEL,
422
 
                                 GTK_RESPONSE_CANCEL);
 
413
  infobar = gtk_info_bar_new_with_buttons (_("S_ubmit Album"), GTK_RESPONSE_OK,
 
414
                                           GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 
415
                                           NULL);
423
416
 
424
417
  /* Translators: title, artist */
425
418
  primary_text = g_strdup_printf (_("Could not find %s by %s on MusicBrainz."), title, artist);
426
419
 
427
 
  set_message_area_text_and_icon (GEDIT_MESSAGE_AREA (message_area),
428
 
                                  "gtk-dialog-info",
429
 
                                  primary_text,
430
 
                                  _("You can improve the MusicBrainz database by adding this album."),
431
 
                                  button);
 
420
  set_info_bar_text_and_icon (GTK_INFO_BAR (infobar),
 
421
                              "gtk-dialog-info",
 
422
                              primary_text,
 
423
                              _("You can improve the MusicBrainz database by adding this album."),
 
424
                              button);
432
425
 
433
426
  g_free (primary_text);
434
427
 
435
 
  return message_area;
 
428
  return infobar;
436
429
}
437
430
 
438
431
static void
439
 
musicbrainz_submit_message_area_response (GeditMessageArea *message_area,
440
 
                                          int response_id,
441
 
                                          gpointer user_data)
 
432
musicbrainz_submit_info_bar_response (GtkInfoBar *infobar,
 
433
                                      int         response_id,
 
434
                                      gpointer    user_data)
442
435
{
443
436
  if (response_id == GTK_RESPONSE_OK) {
444
437
    on_submit_activate (NULL, NULL);
550
543
 
551
544
    /* If album details don't come from MusicBrainz ask user to add them */
552
545
    if (album->metadata_source != SOURCE_MUSICBRAINZ) {
553
 
      GtkWidget *message_area;
554
 
 
555
 
      message_area = musicbrainz_submit_message_area_new (album->title, album->artist);
556
 
 
557
 
      set_message_area (message_area_eventbox, message_area);
558
 
 
559
 
      g_signal_connect (message_area,
 
546
      GtkWidget *infobar;
 
547
 
 
548
      infobar = musicbrainz_submit_info_bar_new (album->title, album->artist);
 
549
 
 
550
      set_message_area (message_area_eventbox, infobar);
 
551
 
 
552
      g_signal_connect (infobar,
560
553
                        "response",
561
 
                        G_CALLBACK (musicbrainz_submit_message_area_response),
 
554
                        G_CALLBACK (musicbrainz_submit_info_bar_response),
562
555
                        NULL);
563
556
 
564
 
      gedit_message_area_set_default_response (GEDIT_MESSAGE_AREA (message_area),
565
 
                                               GTK_RESPONSE_CANCEL);
 
557
      gtk_info_bar_set_default_response (GTK_INFO_BAR (infobar),
 
558
                                         GTK_RESPONSE_CANCEL);
566
559
 
567
 
      gtk_widget_show (message_area);
 
560
      gtk_widget_show (infobar);
568
561
    }
569
562
  }
570
563
}
614
607
    GtkTreeViewColumn *column;
615
608
    GtkCellRenderer *text_renderer = gtk_cell_renderer_text_new ();
616
609
 
617
 
    dialog = glade_xml_get_widget (glade, "multiple_dialog");
 
610
    dialog = GET_WIDGET ("multiple_dialog");
618
611
    g_assert (dialog != NULL);
619
612
    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (main_window));
620
 
    albums_listview = glade_xml_get_widget (glade, "albums_listview");
621
 
    ok_button = glade_xml_get_widget (glade, "ok_button");
 
613
    albums_listview = GET_WIDGET ("albums_listview");
 
614
    ok_button       = GET_WIDGET ("ok_button");
622
615
 
623
616
    g_signal_connect (albums_listview, "row-activated", G_CALLBACK (album_row_activated), dialog);
624
617
 
784
777
{
785
778
  g_assert (strcmp (entry->key, GCONF_AUDIO_VOLUME) == 0);
786
779
 
787
 
  GtkWidget *volb = glade_xml_get_widget (glade, "volume_button");
 
780
  GtkWidget *volb = GET_WIDGET ("volume_button");
788
781
  if (entry->value == NULL) {
789
782
    gtk_scale_button_set_value (GTK_SCALE_BUTTON (volb), 1.0);
790
783
  } else {
795
788
static void
796
789
metadata_cb (SjMetadataGetter *m, GList *albums, GError *error)
797
790
{
798
 
  gboolean realized = GTK_WIDGET_REALIZED (main_window);
 
791
  gboolean realized = gtk_widget_get_realized (main_window);
799
792
 
800
793
  if (realized)
801
 
    gdk_window_set_cursor (main_window->window, NULL);
 
794
    gdk_window_set_cursor (gtk_widget_get_window (main_window), NULL);
802
795
    /* Clear the statusbar message */
803
796
    gtk_statusbar_pop(GTK_STATUSBAR(status_bar), 0);
804
797
 
805
798
  if (error && !(error->code == SJ_ERROR_CD_NO_MEDIA)) {
806
799
    GtkWidget *dialog;
807
800
 
808
 
    dialog = gtk_message_dialog_new (realized ? GTK_WINDOW (main_window) : NULL, 0,
809
 
                                     GTK_MESSAGE_ERROR,
810
 
                                     GTK_BUTTONS_CLOSE,
811
 
                                     "<b>%s</b>\n\n%s\n%s: %s",
812
 
                                     _("Could not read the CD"),
813
 
                                     _("Sound Juicer could not read the track listing on this CD."),
814
 
                                     _("Reason"),
815
 
                                     error->message);
816
 
    gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
 
801
    dialog = gtk_message_dialog_new_with_markup (realized ? GTK_WINDOW (main_window) : NULL, 0,
 
802
                                                 GTK_MESSAGE_ERROR,
 
803
                                                 GTK_BUTTONS_CLOSE,
 
804
                                                 "<b>%s</b>\n\n%s\n%s: %s",
 
805
                                                 _("Could not read the CD"),
 
806
                                                 _("Sound Juicer could not read the track listing on this CD."),
 
807
                                                 _("Reason"),
 
808
                                                 error->message);
817
809
    gtk_dialog_run (GTK_DIALOG (dialog));
818
810
    gtk_widget_destroy (dialog);
819
811
    update_ui_for_album (NULL);
884
876
  /* TODO: remove ignore_no_media? */
885
877
  GError *error = NULL;
886
878
  GdkCursor *cursor;
887
 
  gboolean realized = GTK_WIDGET_REALIZED (main_window);
 
879
  GdkWindow *window;
 
880
  gboolean realized = gtk_widget_get_realized (main_window);
 
881
 
 
882
  window = gtk_widget_get_window (main_window);
888
883
 
889
884
  /* Make sure nothing is playing */
890
885
  stop_playback ();
891
886
 
892
887
  /* Set watch cursor */
893
888
  if (realized) {
894
 
    cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (main_window->window), GDK_WATCH);
895
 
    gdk_window_set_cursor (main_window->window, cursor);
 
889
    cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (window), GDK_WATCH);
 
890
    gdk_window_set_cursor (window, cursor);
896
891
    gdk_cursor_unref (cursor);
897
 
    gdk_display_sync (gdk_drawable_get_display (main_window->window));
 
892
    gdk_display_sync (gdk_drawable_get_display (window));
898
893
  }
899
894
 
900
895
  /* Set statusbar message */
912
907
    update_ui_for_album (NULL);
913
908
    gtk_statusbar_pop(GTK_STATUSBAR(status_bar), 0);
914
909
    if (realized)
915
 
      gdk_window_set_cursor (main_window->window, NULL);
 
910
      gdk_window_set_cursor (window, NULL);
916
911
    return;
917
912
  }
918
913
 
925
920
                                     GTK_MESSAGE_ERROR,
926
921
                                     GTK_BUTTONS_CLOSE,
927
922
                                     "%s", _("Could not read the CD"));
928
 
    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
929
 
                                              "%s\n%s: %s",
930
 
                                              _("Sound Juicer could not read the track listing on this CD."),
931
 
                                              _("Reason"),
932
 
                                              error->message);
 
923
    gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog),
 
924
                                                "%s\n%s: %s",
 
925
                                                _("Sound Juicer could not read the track listing on this CD."),
 
926
                                                _("Reason"),
 
927
                                                error->message);
933
928
 
934
 
    gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
935
929
    gtk_dialog_run (GTK_DIALOG (dialog));
936
930
    gtk_widget_destroy (dialog);
937
931
    g_error_free (error);
989
983
    GtkWidget *dialog;
990
984
    char *message;
991
985
    message = g_strdup_printf (_("Sound Juicer could not use the CD-ROM device '%s'"), device);
992
 
    dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
993
 
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
994
 
                                     GTK_MESSAGE_ERROR,
995
 
                                     GTK_BUTTONS_CLOSE,
996
 
                                     "<b>%s</b>\n\n%s",
997
 
                                     message,
998
 
                                     _("HAL daemon may not be running."));
 
986
    dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
 
987
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
 
988
                                                 GTK_MESSAGE_ERROR,
 
989
                                                 GTK_BUTTONS_CLOSE,
 
990
                                                 "<b>%s</b>\n\n%s",
 
991
                                                 message,
 
992
                                                 _("HAL daemon may not be running."));
999
993
    g_free (message);
1000
 
    gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
1001
994
    gtk_dialog_run (GTK_DIALOG (dialog));
1002
995
    gtk_widget_destroy (dialog);
1003
996
    return;
1022
1015
    error = g_strerror (errno);
1023
1016
    message = g_strdup_printf (_("Sound Juicer could not access the CD-ROM device '%s'"), device);
1024
1017
 
1025
 
    dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
1026
 
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
1027
 
                                     GTK_MESSAGE_ERROR,
1028
 
                                     GTK_BUTTONS_CLOSE,
1029
 
                                     "<b>%s</b>\n\n%s\n%s: %s",
1030
 
                                     _("Could not read the CD"),
1031
 
                                     message,
1032
 
                                     _("Reason"),
1033
 
                                     error);
 
1018
    dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
 
1019
                                                 GTK_DIALOG_DESTROY_WITH_PARENT,
 
1020
                                                 GTK_MESSAGE_ERROR,
 
1021
                                                 GTK_BUTTONS_CLOSE,
 
1022
                                                 "<b>%s</b>\n\n%s\n%s: %s",
 
1023
                                                 _("Could not read the CD"),
 
1024
                                                 message,
 
1025
                                                 _("Reason"),
 
1026
                                                 error);
1034
1027
    g_free (message);
1035
1028
 
1036
 
    gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
1037
1029
    gtk_dialog_run (GTK_DIALOG (dialog));
1038
1030
    gtk_widget_destroy (dialog);
1039
1031
 
1114
1106
    if (device == NULL) {
1115
1107
#ifndef IGNORE_MISSING_CD
1116
1108
      GtkWidget *dialog;
1117
 
      dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
1118
 
                                       GTK_DIALOG_DESTROY_WITH_PARENT,
1119
 
                                       GTK_MESSAGE_ERROR,
1120
 
                                       GTK_BUTTONS_CLOSE,
1121
 
                                       "<b>%s</b>\n\n%s",
1122
 
                                       _("No CD-ROM drives found"),
1123
 
                                       _("Sound Juicer could not find any CD-ROM drives to read."));
1124
 
      gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
 
1109
      dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
 
1110
                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
 
1111
                                                   GTK_MESSAGE_ERROR,
 
1112
                                                   GTK_BUTTONS_CLOSE,
 
1113
                                                   "<b>%s</b>\n\n%s",
 
1114
                                                   _("No CD-ROM drives found"),
 
1115
                                                   _("Sound Juicer could not find any CD-ROM drives to read."));
1125
1116
      gtk_dialog_run (GTK_DIALOG (dialog));
1126
1117
      gtk_widget_destroy (dialog);
1127
1118
      exit (1);
1218
1209
/**
1219
1210
 * Clicked on Reread in the UI (button/menu)
1220
1211
 */
1221
 
void on_reread_activate (GtkWidget *button, gpointer user_data)
 
1212
G_MODULE_EXPORT void on_reread_activate (GtkWidget *button, gpointer user_data)
1222
1213
{
1223
1214
  reread_cd (FALSE);
1224
1215
}
1226
1217
/**
1227
1218
 * Clicked the Submit menu item in the UI
1228
1219
 */
1229
 
void on_submit_activate (GtkWidget *menuitem, gpointer user_data)
 
1220
G_MODULE_EXPORT void on_submit_activate (GtkWidget *menuitem, gpointer user_data)
1230
1221
{
1231
1222
  GError *error = NULL;
1232
1223
 
1234
1225
      if (!gtk_show_uri (NULL, current_submit_url, GDK_CURRENT_TIME, &error)) {
1235
1226
      GtkWidget *dialog;
1236
1227
 
1237
 
      dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
1238
 
                                       GTK_DIALOG_DESTROY_WITH_PARENT,
1239
 
                                       GTK_MESSAGE_ERROR,
1240
 
                                       GTK_BUTTONS_CLOSE,
1241
 
                                       "<b>%s</b>\n\n%s\n%s: %s",
1242
 
                                       _("Could not open URL"),
1243
 
                                       _("Sound Juicer could not open the submission URL"),
1244
 
                                       _("Reason"),
1245
 
                                       error->message);
1246
 
      gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
 
1228
      dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
 
1229
                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
 
1230
                                                   GTK_MESSAGE_ERROR,
 
1231
                                                   GTK_BUTTONS_CLOSE,
 
1232
                                                   "<b>%s</b>\n\n%s\n%s: %s",
 
1233
                                                   _("Could not open URL"),
 
1234
                                                   _("Sound Juicer could not open the submission URL"),
 
1235
                                                   _("Reason"),
 
1236
                                                   error->message);
1247
1237
      gtk_dialog_run (GTK_DIALOG (dialog));
1248
1238
      gtk_widget_destroy (dialog);
1249
1239
      g_error_free (error);
1386
1376
#undef UNSET
1387
1377
}
1388
1378
 
1389
 
void on_title_edit_changed(GtkEditable *widget, gpointer user_data) {
 
1379
G_MODULE_EXPORT void on_title_edit_changed(GtkEditable *widget, gpointer user_data) {
1390
1380
  g_return_if_fail (current_album != NULL);
1391
1381
 
1392
1382
  remove_musicbrainz_ids (current_album);
1397
1387
  current_album->title = gtk_editable_get_chars (widget, 0, -1); /* get all the characters */
1398
1388
}
1399
1389
 
1400
 
void on_artist_edit_changed(GtkEditable *widget, gpointer user_data) {
 
1390
G_MODULE_EXPORT void on_artist_edit_changed(GtkEditable *widget, gpointer user_data) {
1401
1391
  GtkTreeIter iter;
1402
1392
  TrackDetails *track;
1403
1393
  gchar *current_track_artist, *former_album_artist = NULL;
1444
1434
  g_free (former_album_artist);
1445
1435
}
1446
1436
 
1447
 
void on_genre_edit_changed(GtkEditable *widget, gpointer user_data) {
 
1437
G_MODULE_EXPORT void on_genre_edit_changed(GtkEditable *widget, gpointer user_data) {
1448
1438
  g_return_if_fail (current_album != NULL);
1449
1439
  if (current_album->genre) {
1450
1440
    g_free (current_album->genre);
1452
1442
  current_album->genre = gtk_editable_get_chars (widget, 0, -1); /* get all the characters */
1453
1443
}
1454
1444
 
1455
 
void on_year_edit_changed(GtkEditable *widget, gpointer user_data) {
 
1445
G_MODULE_EXPORT void on_year_edit_changed(GtkEditable *widget, gpointer user_data) {
1456
1446
  const gchar* yearstr;
1457
1447
  int year;
1458
1448
 
1469
1459
  }
1470
1460
}
1471
1461
 
1472
 
void on_disc_number_edit_changed(GtkEditable *widget, gpointer user_data) {
 
1462
G_MODULE_EXPORT void on_disc_number_edit_changed(GtkEditable *widget, gpointer user_data) {
1473
1463
    const gchar* discstr;
1474
1464
    int disc_number;
1475
1465
 
1479
1469
    current_album->disc_number = disc_number;
1480
1470
}
1481
1471
 
1482
 
void on_contents_activate(GtkWidget *button, gpointer user_data) {
 
1472
G_MODULE_EXPORT void on_contents_activate(GtkWidget *button, gpointer user_data) {
1483
1473
  GError *error = NULL;
1484
1474
 
1485
1475
  gtk_show_uri (NULL, "ghelp:sound-juicer", GDK_CURRENT_TIME, &error);
1581
1571
/**
1582
1572
 * Clicked on duplicate in the UI (button/menu)
1583
1573
 */
1584
 
void on_duplicate_activate (GtkWidget *button, gpointer user_data)
 
1574
G_MODULE_EXPORT void on_duplicate_activate (GtkWidget *button, gpointer user_data)
1585
1575
{
1586
1576
  GError *error = NULL;
1587
1577
  const gchar* device;
1590
1580
  if (!g_spawn_command_line_async (g_strconcat ("brasero -c ", device, NULL), &error)) {
1591
1581
      GtkWidget *dialog;
1592
1582
 
1593
 
      dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
1594
 
                                       GTK_DIALOG_DESTROY_WITH_PARENT,
1595
 
                                       GTK_MESSAGE_ERROR,
1596
 
                                       GTK_BUTTONS_CLOSE,
1597
 
                                       "<b>%s</b>\n\n%s\n%s: %s",
1598
 
                                       _("Could not duplicate disc"),
1599
 
                                       _("Sound Juicer could not duplicate the disc"),
1600
 
                                       _("Reason"),
1601
 
                                       error->message);
1602
 
      gtk_label_set_use_markup (GTK_LABEL (GTK_MESSAGE_DIALOG (dialog)->label), TRUE);
 
1583
      dialog = gtk_message_dialog_new_with_markup (GTK_WINDOW (main_window),
 
1584
                                                   GTK_DIALOG_DESTROY_WITH_PARENT,
 
1585
                                                   GTK_MESSAGE_ERROR,
 
1586
                                                   GTK_BUTTONS_CLOSE,
 
1587
                                                   "<b>%s</b>\n\n%s\n%s: %s",
 
1588
                                                   _("Could not duplicate disc"),
 
1589
                                                   _("Sound Juicer could not duplicate the disc"),
 
1590
                                                   _("Reason"),
 
1591
                                                   error->message);
1603
1592
      gtk_dialog_run (GTK_DIALOG (dialog));
1604
1593
      gtk_widget_destroy (dialog);
1605
1594
      g_error_free (error);
1702
1691
  /* init gnome-media-profiles */
1703
1692
  gnome_media_profiles_init (gconf_client);
1704
1693
 
1705
 
  glade_init ();
1706
 
  if (g_file_test (SOURCE_GLADE, G_FILE_TEST_EXISTS) != FALSE) {
1707
 
    glade = glade_xml_new (SOURCE_GLADE, NULL, NULL);
 
1694
  builder = gtk_builder_new ();
 
1695
  if (g_file_test (SOURCE_BUILDER, G_FILE_TEST_EXISTS) != FALSE) {
 
1696
    gtk_builder_add_from_file (builder, SOURCE_BUILDER, &error);
1708
1697
  } else {
1709
 
    glade = glade_xml_new (INSTALLED_GLADE, NULL, NULL);
 
1698
    gtk_builder_add_from_file (builder, INSTALLED_BUILDER, &error);
1710
1699
  }
1711
 
  if (glade == NULL) {
1712
 
    error = g_error_new (g_quark_from_static_string ("sound-juicer"),
1713
 
                         1, /* this is made up */
1714
 
                         _("The interface file for Sound Juicer could not be read."));
 
1700
 
 
1701
  if (error != NULL) {
1715
1702
    error_on_start (error);
1716
1703
    g_error_free (error);
1717
1704
    exit (1);
1718
1705
  }
1719
 
  glade_xml_signal_autoconnect (glade);
1720
 
 
1721
 
  main_window = glade_xml_get_widget (glade, "main_window");
1722
 
  message_area_eventbox = glade_xml_get_widget (glade, "message_area_eventbox");
1723
 
  select_all_menuitem = glade_xml_get_widget (glade, "select_all");
1724
 
  deselect_all_menuitem = glade_xml_get_widget (glade, "deselect_all");
1725
 
  submit_menuitem = glade_xml_get_widget (glade, "submit");
1726
 
  title_entry = glade_xml_get_widget (glade, "title_entry");
1727
 
  artist_entry = glade_xml_get_widget (glade, "artist_entry");
1728
 
  duration_label = glade_xml_get_widget (glade, "duration_label");
1729
 
  genre_entry = glade_xml_get_widget (glade, "genre_entry");
1730
 
  year_entry = glade_xml_get_widget (glade, "year_entry");
1731
 
  disc_number_entry = glade_xml_get_widget (glade, "disc_number_entry");
1732
 
  track_listview = glade_xml_get_widget (glade, "track_listview");
1733
 
  extract_button = glade_xml_get_widget (glade, "extract_button");
1734
 
  extract_menuitem = glade_xml_get_widget (glade, "extract_menuitem");
1735
 
  play_button = glade_xml_get_widget (glade, "play_button");
1736
 
  play_menuitem = glade_xml_get_widget (glade, "play_menuitem");
1737
 
  next_menuitem = glade_xml_get_widget (glade, "next_track_menuitem");
1738
 
  prev_menuitem = glade_xml_get_widget (glade, "previous_track_menuitem");
1739
 
  status_bar = glade_xml_get_widget (glade, "status_bar");
1740
 
  duplicate = glade_xml_get_widget (glade, "duplicate_menuitem");
1741
 
  eject = glade_xml_get_widget (glade, "eject");
 
1706
 
 
1707
  gtk_builder_connect_signals (builder, NULL);
 
1708
 
 
1709
  main_window           = GET_WIDGET ("main_window");
 
1710
  message_area_eventbox = GET_WIDGET ("message_area_eventbox");
 
1711
  select_all_menuitem   = GET_WIDGET ("select_all");
 
1712
  deselect_all_menuitem = GET_WIDGET ("deselect_all");
 
1713
  submit_menuitem       = GET_WIDGET ("submit");
 
1714
  title_entry           = GET_WIDGET ("title_entry");
 
1715
  artist_entry          = GET_WIDGET ("artist_entry");
 
1716
  duration_label        = GET_WIDGET ("duration_label");
 
1717
  genre_entry           = GET_WIDGET ("genre_entry");
 
1718
  year_entry            = GET_WIDGET ("year_entry");
 
1719
  disc_number_entry     = GET_WIDGET ("disc_number_entry");
 
1720
  track_listview        = GET_WIDGET ("track_listview");
 
1721
  extract_button        = GET_WIDGET ("extract_button");
 
1722
  extract_menuitem      = GET_WIDGET ("extract_menuitem");
 
1723
  play_button           = GET_WIDGET ("play_button");
 
1724
  play_menuitem         = GET_WIDGET ("play_menuitem");
 
1725
  next_menuitem         = GET_WIDGET ("next_track_menuitem");
 
1726
  prev_menuitem         = GET_WIDGET ("previous_track_menuitem");
 
1727
  status_bar            = GET_WIDGET ("status_bar");
 
1728
  duplicate             = GET_WIDGET ("duplicate_menuitem");
 
1729
  eject                 = GET_WIDGET ("eject");
1742
1730
 
1743
1731
  { /* ensure that the play/pause button's size is constant */
1744
1732
    GtkWidget *fake_button1, *fake_button2;