Replace gnome_app_ok_cancel_modal() with Gtk dialog
authorHugo Villeneuve <hugo@hugovil.com>
Mon, 5 Sep 2011 18:19:03 +0000 (14:19 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Tue, 25 Mar 2014 03:27:04 +0000 (23:27 -0400)
src/cdplay.c
src/cdplay.h
src/dialog.c
src/dialog.h
src/discedit.c
src/grip.c
src/rip.c

index deb77d5..5a30509 100644 (file)
@@ -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");
index 5b57979..0b3af61 100644 (file)
@@ -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);
index 8e85436..70d1805 100644 (file)
 #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;
index 94488bc..07062f5 100644 (file)
  */
 
 /* 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,
index 4b7baa4..d953741 100644 (file)
@@ -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*/
index 555e648..3b74664 100644 (file)
@@ -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
index 7d87f0e..3b555b4 100644 (file)
--- 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;