~unity-team/unity/trusty-1066971

« back to all changes in this revision

Viewing changes to unity-shared/DecorationStyle.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2014-04-02 17:05:04 UTC
  • mto: This revision was merged to the branch mainline in revision 3770.
  • Revision ID: mail@3v1n0.net-20140402170504-pld35vkemus6160j
DecorationStyle: add WindowManagerAction to get WM click options

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
const std::string SETTINGS_NAME = "org.gnome.desktop.wm.preferences";
62
62
const std::string FONT_KEY = "titlebar-font";
63
63
const std::string USE_SYSTEM_FONT_KEY = "titlebar-uses-system-font";
 
64
const std::string ACTION_DOUBLE_CLICK = "action-double-click-titlebar";
 
65
const std::string ACTION_MIDDLE_CLICK = "action-middle-click-titlebar";
 
66
const std::string ACTION_RIGHT_CLICK = "action-right-click-titlebar";
64
67
 
65
68
const std::string UNITY_SETTINGS_NAME = "com.canonical.Unity.Decorations";
66
69
const std::string GRAB_WAIT_KEY = "grab-wait";
299
302
    return value;
300
303
  }
301
304
 
 
305
  WMAction WMActionFromString(std::string const& action) const
 
306
  {
 
307
    if (action == "toggle-shade")
 
308
      return WMAction::TOGGLE_SHADE;
 
309
    else if (action == "toggle-maximize")
 
310
      return WMAction::TOGGLE_MAXIMIZE;
 
311
    else if (action == "toggle-maximize-horizontally")
 
312
      return WMAction::TOGGLE_MAXIMIZE_HORIZONTALLY;
 
313
    else if (action == "toggle-maximize-vertically")
 
314
      return WMAction::TOGGLE_MAXIMIZE_VERTICALLY;
 
315
    else if (action == "minimize")
 
316
      return WMAction::MINIMIZE;
 
317
    else if (action == "shade")
 
318
      return WMAction::SHADE;
 
319
    else if (action == "menu")
 
320
      return WMAction::MENU;
 
321
    else if (action == "lower")
 
322
      return WMAction::LOWER;
 
323
 
 
324
    return WMAction::NONE;
 
325
  }
 
326
 
 
327
  WMAction WindowManagerAction(WMEvent event) const
 
328
  {
 
329
    std::string action_setting;
 
330
 
 
331
    switch (event)
 
332
    {
 
333
      case WMEvent::DOUBLE_CLICK:
 
334
        action_setting = ACTION_DOUBLE_CLICK;
 
335
        break;
 
336
      case WMEvent::MIDDLE_CLICK:
 
337
        action_setting = ACTION_MIDDLE_CLICK;
 
338
        break;
 
339
      case WMEvent::RIGHT_CLICK:
 
340
        action_setting = ACTION_RIGHT_CLICK;
 
341
        break;
 
342
    }
 
343
 
 
344
    glib::String action_string(g_settings_get_string(settings_, action_setting.c_str()));
 
345
    return WMActionFromString(action_string.Str());
 
346
  }
 
347
 
302
348
  inline GtkStateFlags GtkStateFromWidgetState(WidgetState ws)
303
349
  {
304
350
    switch (ws)
776
822
  return impl_->glow_color_;
777
823
}
778
824
 
 
825
WMAction Style::WindowManagerAction(WMEvent event) const
 
826
{
 
827
  return impl_->WindowManagerAction(event);
 
828
}
 
829
 
779
830
int Style::DoubleClickMaxDistance() const
780
831
{
781
832
  return impl_->GetSettingValue<int>("gtk-double-click-distance");