From 64cdc5a741a2ab7cb8666e81be138657a0fea46e Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Mon, 5 Sep 2011 14:19:03 -0400 Subject: [PATCH] Replace gnome_app_ok_cancel_modal() with Gtk dialog --- src/cdplay.c | 7 ++----- src/cdplay.h | 2 +- src/dialog.c | 18 ++++++++++++++++++ src/dialog.h | 6 ++++++ src/discedit.c | 10 ++++------ src/grip.c | 12 +++++------- src/rip.c | 9 +++------ 7 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/cdplay.c b/src/cdplay.c index deb77d5..5a30509 100644 --- a/src/cdplay.c +++ b/src/cdplay.c @@ -1887,8 +1887,7 @@ void UpdateTracks(GripInfo *ginfo) } if(ginfo->ask_submit) { - gnome_app_ok_cancel_modal - ((GnomeApp *)uinfo->app, + DisplayOkCancelDialog(GTK_WINDOW(uinfo->app), _("This disc has been found on your secondary server,\n" "but not on your primary server.\n\n" "Do you wish to submit this disc information?"), @@ -1900,7 +1899,7 @@ void UpdateTracks(GripInfo *ginfo) ginfo->first_time=0; } -void SubmitEntry(gint reply,gpointer data) +void SubmitEntry(gpointer data) { GripInfo *ginfo; int fd; @@ -1908,8 +1907,6 @@ void SubmitEntry(gint reply,gpointer data) char mailcmd[256]; char filename[256]; - if(reply) return; - ginfo=(GripInfo *)data; sprintf(filename,"/tmp/grip.XXXXXX"); diff --git a/src/cdplay.h b/src/cdplay.h index 5b57979..0b3af61 100644 --- a/src/cdplay.h +++ b/src/cdplay.h @@ -70,7 +70,7 @@ void CheckNewDisc(GripInfo *ginfo,gboolean force); void ScanDisc(GtkWidget *widget,gpointer data); void UpdateDisplay(GripInfo *ginfo); void UpdateTracks(GripInfo *ginfo); -void SubmitEntry(gint reply,gpointer data); +void SubmitEntry(gpointer data); void PlayTrackCB(GtkWidget *widget,gpointer data); void StopPlayCB(GtkWidget *widget,gpointer data); diff --git a/src/dialog.c b/src/dialog.c index 8e85436..70d1805 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -27,6 +27,24 @@ #include "common.h" #include "dialog.h" +void DisplayOkCancelDialog(GtkWindow *window, char *msg, + GripReplyCallback callback, gpointer data) +{ + GtkWidget *dialog; + gint response; + + dialog = gtk_message_dialog_new(window, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_OK_CANCEL, + msg); + response = gtk_dialog_run(GTK_DIALOG(dialog)); + if(response == GTK_RESPONSE_OK) { + callback(data); + } + gtk_widget_destroy(dialog); +} + void DisplayWarningMsg(GtkWindow *window, char *msg) { GtkWidget *dialog; diff --git a/src/dialog.h b/src/dialog.h index 94488bc..07062f5 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -21,6 +21,12 @@ */ /* Message routines */ + +typedef void (*GripReplyCallback)(gpointer data); + +void DisplayOkCancelDialog(GtkWindow *window, char *msg, + GripReplyCallback callback, gpointer data); + void DisplayWarningMsg(GtkWindow *window, char *msg); void DisplayErrorMsg(GtkWindow *window, char *msg); void BoolDialog(char *question,char *yes,GtkSignalFunc yesfunc, diff --git a/src/discedit.c b/src/discedit.c index 4b7baa4..d953741 100644 --- a/src/discedit.c +++ b/src/discedit.c @@ -570,19 +570,17 @@ static void SubmitEntryCB(GtkWidget *widget,gpointer data) len=strlen(ginfo->discdb_submit_email); if(!strncasecmp(ginfo->discdb_submit_email+(len-9),".cddb.com",9)) - gnome_app_ok_cancel_modal - ((GnomeApp *)ginfo->gui_info.app, + DisplayOkCancelDialog(GTK_WINDOW(ginfo->gui_info.app), _("You are about to submit this disc information\n" "to a commercial CDDB server, which will then\n" "own the data that you submit. These servers make\n" "a profit out of your effort. We suggest that you\n" "support free servers instead.\n\nContinue?"), - (GnomeReplyCallback)SubmitEntry,(gpointer)ginfo); + SubmitEntry, (gpointer)ginfo); else - gnome_app_ok_cancel_modal - ((GnomeApp *)ginfo->gui_info.app, + DisplayOkCancelDialog(GTK_WINDOW(ginfo->gui_info.app), _("You are about to submit this\ndisc information via email.\n\n" - "Continue?"),(GnomeReplyCallback)SubmitEntry,(gpointer)ginfo); + "Continue?"), SubmitEntry, (gpointer)ginfo); } /* Make the user pick a DiscDB genre on submit*/ diff --git a/src/grip.c b/src/grip.c index 555e648..3b74664 100644 --- a/src/grip.c +++ b/src/grip.c @@ -42,7 +42,7 @@ #include "parsecfg.h" #include "tray.h" -static void ReallyDie(gint reply,gpointer data); +static void ReallyDie(gpointer data); static void MakeStatusPage(GripInfo *ginfo); static void DoHelp(GtkWidget *widget,gpointer data); static void MakeHelpPage(GripInfo *ginfo); @@ -340,21 +340,19 @@ void GripDie(GtkWidget *widget,gpointer data) #ifndef GRIPCD if(ginfo->ripping_a_disc || ginfo->encoding) - gnome_app_ok_cancel_modal((GnomeApp *)ginfo->gui_info.app, + DisplayOkCancelDialog(GTK_WINDOW(ginfo->gui_info.app), _("Work is in progress.\nReally shut down?"), ReallyDie,(gpointer)ginfo); - else ReallyDie(0,ginfo); + else ReallyDie(ginfo); #else - ReallyDie(0,ginfo); + ReallyDie(ginfo); #endif } -static void ReallyDie(gint reply,gpointer data) +static void ReallyDie(gpointer data) { GripInfo *ginfo; - if(reply) return; - ginfo=(GripInfo *)data; #ifndef GRIPCD diff --git a/src/rip.c b/src/rip.c index 7d87f0e..3b555b4 100644 --- a/src/rip.c +++ b/src/rip.c @@ -64,7 +64,7 @@ static void DoWavFilter(GripInfo *ginfo); static void DoDiscFilter(GripInfo *ginfo); static void RipIsFinished(GripInfo *ginfo,gboolean aborted); static void CheckDupNames(GripInfo *ginfo); -static void RipWholeCD(gint reply,gpointer data); +static void RipWholeCD(gpointer data); static int NextTrackToRip(GripInfo *ginfo); static gboolean RipNextTrack(GripInfo *ginfo); #ifdef CDPAR @@ -1318,8 +1318,7 @@ void DoRip(GtkWidget *widget,gpointer data) } if(NextTrackToRip(ginfo)==ginfo->disc.num_tracks) { - gnome_app_ok_cancel_modal - ((GnomeApp *)ginfo->gui_info.app, + DisplayOkCancelDialog(GTK_WINDOW(ginfo->gui_info.app), _("No tracks selected.\nRip whole CD?\n"), RipWholeCD,(gpointer)ginfo); return; @@ -1336,13 +1335,11 @@ void DoRip(GtkWidget *widget,gpointer data) } } -static void RipWholeCD(gint reply,gpointer data) +static void RipWholeCD(gpointer data) { int track; GripInfo *ginfo; - if(reply) return; - Debug(_("Ripping whole CD\n")); ginfo=(GripInfo *)data; -- 2.20.1