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.

WindowFlashing.java 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2006-2014 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.addons.windowflashing;
  23. import com.dmdirc.config.prefs.PluginPreferencesCategory;
  24. import com.dmdirc.config.prefs.PreferencesCategory;
  25. import com.dmdirc.config.prefs.PreferencesDialogModel;
  26. import com.dmdirc.config.prefs.PreferencesSetting;
  27. import com.dmdirc.config.prefs.PreferencesType;
  28. import com.dmdirc.plugins.Exported;
  29. import com.dmdirc.plugins.PluginInfo;
  30. import com.dmdirc.plugins.implementations.BaseCommandPlugin;
  31. import dagger.ObjectGraph;
  32. /**
  33. * Native notification plugin to make DMDirc support windows task bar flashing.
  34. */
  35. public class WindowFlashing extends BaseCommandPlugin {
  36. /** Window flashing manager. */
  37. private WindowFlashingManager manager;
  38. /** This plugin's plugin info. */
  39. private PluginInfo pluginInfo;
  40. public WindowFlashing(final PluginInfo pluginInfo) {
  41. this.pluginInfo = pluginInfo;
  42. }
  43. @Override
  44. public void load(final PluginInfo pluginInfo, final ObjectGraph graph) {
  45. super.load(pluginInfo, graph);
  46. this.pluginInfo = pluginInfo;
  47. setObjectGraph(graph.plus(new WindowFlashingModule()));
  48. registerCommand(FlashWindow.class, FlashWindow.INFO);
  49. manager = getObjectGraph().get(WindowFlashingManager.class);
  50. }
  51. /**
  52. * Flashes an inactive window under windows, used as a showNotifications exported command
  53. *
  54. * @param title Unused
  55. * @param message Unused
  56. */
  57. @Exported
  58. public void flashNotification(final String title, final String message) {
  59. manager.flashWindow();
  60. }
  61. @Override
  62. public void onLoad() {
  63. super.onLoad();
  64. manager.onLoad();
  65. }
  66. @Override
  67. public void onUnload() {
  68. super.onUnload();
  69. manager.onUnload();
  70. }
  71. @Override
  72. public void showConfig(final PreferencesDialogModel manager) {
  73. final PreferencesCategory category = new PluginPreferencesCategory(
  74. pluginInfo, "Window Flashing",
  75. "General configuration for window flashing plugin.");
  76. category.addSetting(new PreferencesSetting(
  77. PreferencesType.OPTIONALINTEGER, pluginInfo.getDomain(), "blinkrate",
  78. "Blink rate", "Specifies the rate at which the taskbar and or "
  79. + "caption will blink, if unspecified this will be your cursor "
  80. + "blink rate.",
  81. manager.getConfigManager(), manager.getIdentity()));
  82. category.addSetting(new PreferencesSetting(
  83. PreferencesType.OPTIONALINTEGER, pluginInfo.getDomain(), "flashcount",
  84. "Flash count", "Specifies the number of times to blink, if "
  85. + "unspecified this will blink indefinitely",
  86. manager.getConfigManager(), manager.getIdentity()));
  87. category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  88. pluginInfo.getDomain(), "flashtaskbar", "Flash taskbar",
  89. "Should the taskbar entry flash?",
  90. manager.getConfigManager(), manager.getIdentity()));
  91. category.addSetting(new PreferencesSetting(PreferencesType.BOOLEAN,
  92. pluginInfo.getDomain(), "flashcaption", "Flash caption",
  93. "Should the window caption flash?",
  94. manager.getConfigManager(), manager.getIdentity()));
  95. manager.getCategory("Plugins").addSubCategory(category);
  96. }
  97. }