TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

artsmessage.cc 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. Copyright (C) 2001 Jeff Tranter
  3. tranter@kde.org
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. ------------------------------------------------------------------------
  16. This application displays an error, warning, or informational message
  17. in a dialog. It is normally used by artsd in conjunction with the -m
  18. option. By abstracting this out of artsd, we keep it independent of
  19. any particular graphics toolkit.
  20. This version uses KDE. Equivalent versions could be written using Qt,
  21. Gnome, etc. and used instead.
  22. */
  23. #include <tqregexp.h>
  24. #include <tdelocale.h>
  25. #include <tdeglobal.h>
  26. #include <tdeapplication.h>
  27. #include <tdeaboutdata.h>
  28. #include <tdemessagebox.h>
  29. #include <tdecmdlineargs.h>
  30. // command line options
  31. static TDECmdLineOptions options[] =
  32. {
  33. { "e", 0,0 },
  34. { "error", I18N_NOOP("Display error message (default)"), 0 },
  35. { "w", 0, 0},
  36. { "warning", I18N_NOOP("Display warning message"), 0 },
  37. { "i", 0, 0 },
  38. { "info", I18N_NOOP("Display informational message"), 0 },
  39. { "+message", I18N_NOOP("Message string to be displayed"), 0 },
  40. TDECmdLineLastOption // End of options.
  41. };
  42. TDEAboutData aboutData("artsmessage", I18N_NOOP("artsmessage"), "0.1",
  43. I18N_NOOP("Utility to display aRts error messages"),
  44. TDEAboutData::License_GPL, "(c) 2001, Jeff Tranter", 0, 0, "tranter@kde.org");
  45. int main(int argc, char **argv) {
  46. aboutData.addAuthor("Jeff Tranter", 0, "tranter@kde.org");
  47. TDEGlobal::locale()->setMainCatalogue("tdelibs");
  48. TDECmdLineArgs::init(argc, argv, &aboutData);
  49. TDECmdLineArgs::addCmdLineOptions(options);
  50. TDEApplication app;
  51. TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
  52. TQString msg;
  53. // must be at least one argument
  54. if (args->count() == 0) {
  55. args->usage();
  56. }
  57. // build up message string from remaining arguments
  58. for (int i = 0; i < args->count(); i++) {
  59. if (i == 0)
  60. msg = args->arg(i);
  61. else
  62. msg += TQString(" ") + args->arg(i);
  63. }
  64. const int notifyOptions = 0; // never activate KNotify
  65. if (args->isSet("w")) {
  66. KMessageBox::sorry(0, msg, i18n("Warning"), notifyOptions);
  67. } else if (args->isSet("i")) {
  68. TQString id = msg;
  69. id.replace(TQRegExp("[\\[\\]\\s=]"), "_");
  70. KMessageBox::information(0, msg, i18n("Informational"), id, notifyOptions);
  71. } else {
  72. KMessageBox::error(0, msg, i18n("Error"), notifyOptions);
  73. }
  74. return 0;
  75. }