diff options
| author | Evan McIntire <mcintire.evan@gmail.com> | 2015-12-18 00:00:30 +0000 |
|---|---|---|
| committer | CI Train Bot <ci-train-bot@canonical.com> | 2015-12-18 00:00:30 +0000 |
| commit | 4e42269c9d41d970f40ccfc4d5865dab6ec3eb48 (patch) | |
| tree | a31c3bec644505a66b7fd599a6b8a527bc42e343 | |
| parent | 3824064fb0aacc1c2e77da0725a8c7a2c1dc5dcc (diff) | |
| parent | a1404594e45141f390e7611e7fd12c3a2dd3ad6a (diff) | |
ShortcutHint: Add key shortcut hints for Screenshot and Window Screenshot
Key bindings are dynamically taken from gnome settings. Fixes: #1050195 Approved by: Marco Trevisan (TreviƱo) (bzr r4057)
| -rw-r--r-- | shortcuts/AbstractShortcutHint.h | 3 | ||||
| -rw-r--r-- | shortcuts/CompizShortcutModeller.cpp | 10 | ||||
| -rw-r--r-- | shortcuts/MockShortcutHint.h | 3 | ||||
| -rw-r--r-- | shortcuts/ShortcutHint.cpp | 25 |
4 files changed, 37 insertions, 4 deletions
diff --git a/shortcuts/AbstractShortcutHint.h b/shortcuts/AbstractShortcutHint.h index d17852847..8eb8487fa 100644 --- a/shortcuts/AbstractShortcutHint.h +++ b/shortcuts/AbstractShortcutHint.h @@ -36,7 +36,8 @@ enum class OptionType : unsigned COMPIZ_KEY = 0, COMPIZ_METAKEY, COMPIZ_MOUSE, - HARDCODED + HARDCODED, + GNOME /* GSETTINGS, * GCONF */ }; diff --git a/shortcuts/CompizShortcutModeller.cpp b/shortcuts/CompizShortcutModeller.cpp index 5d4b373fe..d792227f9 100644 --- a/shortcuts/CompizShortcutModeller.cpp +++ b/shortcuts/CompizShortcutModeller.cpp @@ -242,6 +242,16 @@ void CompizModeller::AddMenuHints(std::list<shortcut::AbstractHint::Ptr> &hints) _("Moves focus between indicators."), shortcut::OptionType::HARDCODED, _("Cursor Left or Right"))); + + hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", + _("Take a screenshot."), + shortcut::OptionType::GNOME, + "screenshot")); + + hints.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", + _("Take a screenshot of the current window."), + shortcut::OptionType::GNOME, + "window-screenshot")); } void CompizModeller::AddSwitcherHints(std::list<shortcut::AbstractHint::Ptr> &hints, bool ws_enabled) diff --git a/shortcuts/MockShortcutHint.h b/shortcuts/MockShortcutHint.h index f1317d416..13f964552 100644 --- a/shortcuts/MockShortcutHint.h +++ b/shortcuts/MockShortcutHint.h @@ -59,6 +59,9 @@ public: value = arg1(); shortkey = prefix() + value() + postfix(); return true; + case OptionType::GNOME: + value = arg1(); + return true; } return false; diff --git a/shortcuts/ShortcutHint.cpp b/shortcuts/ShortcutHint.cpp index 8f0d4b225..898374543 100644 --- a/shortcuts/ShortcutHint.cpp +++ b/shortcuts/ShortcutHint.cpp @@ -21,16 +21,19 @@ #include <core/core.h> // Compiz... #include <NuxCore/Logger.h> +#include <UnityCore/GLibWrapper.h> #include "ShortcutHintPrivate.h" -DECLARE_LOGGER(logger, "unity.shortcut"); - namespace unity { namespace shortcut { - +namespace +{ + const std::string GNOME_MEDIA_SETTINGS = "org.gnome.settings-daemon.plugins.media-keys"; + DECLARE_LOGGER(logger, "unity.shortcut"); +} // Ctor Hint::Hint(std::string const& category, std::string const& prefix, @@ -152,6 +155,22 @@ bool Hint::Fill() shortkey = prefix() + value() + postfix(); } return true; + case OptionType::GNOME: + { + glib::Object<GSettings> key_settings(g_settings_new(GNOME_MEDIA_SETTINGS.c_str())); + glib::String key(g_settings_get_string(key_settings, arg1().c_str())); + + std::string temp(impl::GetTranslatableLabel(key.Str())); + temp = impl::ProperCase(temp); + + if (value() != temp) + { + value = temp; + shortkey = value(); + } + + return true; + } default: LOG_WARNING(logger) << "Unable to find the option type" << static_cast<unsigned>(type()); |
