/* void showProgress (in nsIDOMWindow parent, in nsIWebBrowserPrint webBrowserPrint, in nsIPrintSettings printSettings, in nsIObserver openDialogObserver, in boolean isForPrinting, out nsIWebProgressListener webProgressListener, out nsIPrintProgressParams printProgressParams, out boolean notifyOnOpen); */ NS_IMETHODIMP GeckoPrintService::ShowProgress (nsIDOMWindow *aParent, nsIWebBrowserPrint *aWebBrowserPrint, nsIPrintSettings *aPrintSettings, nsIObserver *aOpenDialogObserver, PRBool aIsForPrinting, nsIWebProgressListener **_webProgressListener, nsIPrintProgressParams **_printProgressParams, PRBool *_notifyOnOpen) { /* Print preview */ if (!aIsForPrinting) { return NS_OK; } nsresult rv; nsCOMPtr<nsIDOMWindowInternal> domWin (do_QueryInterface (aParent, &rv)); NS_ENSURE_SUCCESS (rv, rv); nsCOMPtr<nsIPrintSession> session; rv = aPrintSettings->GetPrintSession (getter_AddRefs (session)); NS_ENSURE_TRUE (NS_SUCCEEDED (rv) && session, nsnull); nsCOMPtr<nsIPrintProgress> progress (do_QueryInterface (session, &rv)); NS_ENSURE_SUCCESS (rv, rv); /* Our print session implements those interfaces */ rv = CallQueryInterface (session, _webProgressListener); rv |= CallQueryInterface (session, _printProgressParams); NS_ENSURE_SUCCESS (rv, rv); /* Setting this to PR_FALSE will make gecko immediately start printing * when we return from this function. * If we set this to PR_TRUE, we need to call aOpenDialogObserver::Observe * (topic, subject and data don't matter) when we're ready for printing. */ *_notifyOnOpen = PR_FALSE; return progress->OpenProgressDialog (domWin, nsnull, nsnull, aOpenDialogObserver, _notifyOnOpen); }
//---------------------------------------------------------------------- // Set up to use the "pluggable" Print Progress Dialog nsresult nsMsgPrintEngine::ShowProgressDialog(bool aIsForPrinting, bool& aDoNotify) { nsresult rv; // default to not notifying, that if something here goes wrong // or we aren't going to show the progress dialog we can straight into // reflowing the doc for printing. aDoNotify = false; // Assume we can't do progress and then see if we can bool showProgressDialog = false; // if it is already being shown then don't bother to find out if it should be // so skip this and leave mShowProgressDialog set to FALSE nsCOMPtr<nsIPrefBranch> prefBranch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) { prefBranch->GetBoolPref("print.show_print_progress", &showProgressDialog); } // Turning off the showing of Print Progress in Prefs overrides // whether the calling PS desire to have it on or off, so only check PS if // prefs says it's ok to be on. if (showProgressDialog) { mPrintSettings->GetShowPrintProgress(&showProgressDialog); } // Now open the service to get the progress dialog // If we don't get a service, that's ok, then just don't show progress if (showProgressDialog) { if (!mPrintPromptService) { mPrintPromptService = do_GetService(kPrintingPromptService); } if (mPrintPromptService) { nsCOMPtr<nsIDOMWindow> domWin(do_QueryInterface(mParentWindow)); if (!domWin) { domWin = mWindow; } rv = mPrintPromptService->ShowProgress(domWin, mWebBrowserPrint, mPrintSettings, this, aIsForPrinting, getter_AddRefs(mPrintProgressListener), getter_AddRefs(mPrintProgressParams), &aDoNotify); if (NS_SUCCEEDED(rv)) { showProgressDialog = mPrintProgressListener != nsnull && mPrintProgressParams != nsnull; if (showProgressDialog) { nsIWebProgressListener* wpl = static_cast<nsIWebProgressListener*>(mPrintProgressListener.get()); NS_ASSERTION(wpl, "nsIWebProgressListener is NULL!"); NS_ADDREF(wpl); nsString msg; if (mIsDoingPrintPreview) { GetString(NS_LITERAL_STRING("LoadingMailMsgForPrintPreview").get(), msg); } else { GetString(NS_LITERAL_STRING("LoadingMailMsgForPrint").get(), msg); } if (!msg.IsEmpty()) mPrintProgressParams->SetDocTitle(msg.get()); } } } } return rv; }
void GtkNSSSecurityWarningDialogs::DoDialog (nsIInterfaceRequestor *aContext, const char *aPrefName, GtkMessageType aType, GtkButtonsType aButtons, int aDefaultResponse, const char *aPrimary, const char *aSecondary, const char *aButtonText, PRBool *_retval) { if (_retval) *_retval = PR_FALSE; nsresult rv; PRBool show = PR_TRUE; nsCOMPtr<nsIPrefBranch> prefBranch (do_GetService (NS_PREFSERVICE_CONTRACTID)); if (prefBranch && aPrefName) { rv = prefBranch->GetBoolPref (aPrefName, &show); if (NS_FAILED(rv)) show = PR_TRUE; } char *showOncePref = NULL; PRBool showOnce = PR_FALSE; if (!show && prefBranch && aPrefName) { showOncePref = g_strconcat (aPrefName, ".show_once", NULL); rv = prefBranch->GetBoolPref (showOncePref, &showOnce); if (NS_FAILED (rv)) showOnce = PR_FALSE; } if (!show && !showOnce) { g_free (showOncePref); if (_retval) *_retval = PR_TRUE; return; } AutoJSContextStack stack; rv = stack.Init (); if (NS_FAILED (rv)) return; /* Didn't you know it, mozilla SUCKS! * the "aContext" interface requestor is made from a nsIDOMWindow, * but can only give out a nsIPrompt, from where there's no way to get * the nsIDOMWindow back! * * However GaleonUtils::FindGtkParent falls back to the current active * window so this vageuly works for us at the moment * * https://bugzilla.mozilla.org/show_bug.cgi?id=277587 */ nsCOMPtr<nsIDOMWindow> domWin (do_GetInterface (aContext)); GtkWidget *parent = GaleonUtils::FindGtkParent (domWin); GtkDialogFlags flags = parent ? (GtkDialogFlags)0 : GTK_DIALOG_MODAL; #if GTK_CHECK_VERSION(2,6,0) GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (parent), flags, aType, aButtons, "%s", aPrimary); if (aSecondary) { gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", aSecondary); } #else GtkWidget *dialog = hig_alert_new (GTK_WINDOW (parent), flags, aType == GTK_MESSAGE_INFO ? HIG_ALERT_INFORMATION : HIG_ALERT_CONFIRMATION, aPrimary, aSecondary, NULL); if (aButtons == GTK_BUTTONS_OK) { gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); } else if (aButtons == GTK_BUTTONS_CANCEL) { gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); } else { g_assert_not_reached(); } #endif if (parent && GTK_WINDOW (parent)->group) { gtk_window_group_add_window (GTK_WINDOW (parent)->group, GTK_WINDOW (dialog)); } if (aButtonText) { gtk_dialog_add_button (GTK_DIALOG (dialog), aButtonText, GTK_RESPONSE_ACCEPT); } gtk_dialog_set_default_response (GTK_DIALOG (dialog), aDefaultResponse); int response = gtk_dialog_run (GTK_DIALOG (dialog)); if (_retval) *_retval = response == GTK_RESPONSE_ACCEPT; if (prefBranch && showOncePref && showOnce) { prefBranch->SetBoolPref (showOncePref, PR_FALSE); } gtk_widget_destroy (dialog); g_free (showOncePref); }