PageRenderTime 50ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/app/actions/error-console-actions.c

https://github.com/STRNG/gimp
C | 104 lines | 67 code | 21 blank | 16 comment | 1 complexity | 28090861f462027ea071b67bd1e13a99 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause
  1. /* GIMP - The GNU Image Manipulation Program
  2. * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. *
  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 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "config.h"
  18. #include <gegl.h>
  19. #include <gtk/gtk.h>
  20. #include "libgimpwidgets/gimpwidgets.h"
  21. #include "actions-types.h"
  22. #include "widgets/gimpactiongroup.h"
  23. #include "widgets/gimperrorconsole.h"
  24. #include "widgets/gimphelp-ids.h"
  25. #include "error-console-actions.h"
  26. #include "error-console-commands.h"
  27. #include "gimp-intl.h"
  28. static const GimpActionEntry error_console_actions[] =
  29. {
  30. { "error-console-popup", GIMP_STOCK_WARNING,
  31. NC_("error-console-action", "Error Console Menu"), NULL, NULL, NULL,
  32. GIMP_HELP_ERRORS_DIALOG },
  33. { "error-console-clear", GTK_STOCK_CLEAR,
  34. NC_("error-console-action", "_Clear"), "",
  35. NC_("error-console-action", "Clear error console"),
  36. G_CALLBACK (error_console_clear_cmd_callback),
  37. GIMP_HELP_ERRORS_CLEAR },
  38. { "error-console-select-all", NULL,
  39. NC_("error-console-action", "Select _All"), "",
  40. NC_("error-console-action", "Select all error messages"),
  41. G_CALLBACK (error_console_select_all_cmd_callback),
  42. GIMP_HELP_ERRORS_SELECT_ALL }
  43. };
  44. static const GimpEnumActionEntry error_console_save_actions[] =
  45. {
  46. { "error-console-save-all", GTK_STOCK_SAVE_AS,
  47. NC_("error-console-action", "_Save Error Log to File..."), "",
  48. NC_("error-console-action", "Write all error messages to a file"),
  49. FALSE, FALSE,
  50. GIMP_HELP_ERRORS_SAVE },
  51. { "error-console-save-selection", GTK_STOCK_SAVE_AS,
  52. NC_("error-console-action", "Save S_election to File..."), "",
  53. NC_("error-console-action", "Write the selected error messages to a file"),
  54. TRUE, FALSE,
  55. GIMP_HELP_ERRORS_SAVE }
  56. };
  57. void
  58. error_console_actions_setup (GimpActionGroup *group)
  59. {
  60. gimp_action_group_add_actions (group, "error-console-action",
  61. error_console_actions,
  62. G_N_ELEMENTS (error_console_actions));
  63. gimp_action_group_add_enum_actions (group, "error-console-action",
  64. error_console_save_actions,
  65. G_N_ELEMENTS (error_console_save_actions),
  66. G_CALLBACK (error_console_save_cmd_callback));
  67. }
  68. void
  69. error_console_actions_update (GimpActionGroup *group,
  70. gpointer data)
  71. {
  72. GimpErrorConsole *console = GIMP_ERROR_CONSOLE (data);
  73. gboolean selection;
  74. selection = gtk_text_buffer_get_selection_bounds (console->text_buffer,
  75. NULL, NULL);
  76. #define SET_SENSITIVE(action,condition) \
  77. gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
  78. SET_SENSITIVE ("error-console-clear", TRUE);
  79. SET_SENSITIVE ("error-console-select-all", TRUE);
  80. SET_SENSITIVE ("error-console-save-all", TRUE);
  81. SET_SENSITIVE ("error-console-save-selection", selection);
  82. #undef SET_SENSITIVE
  83. }