~ps-jenkins/unity/trusty-proposed

« back to all changes in this revision

Viewing changes to shutdown/SessionView.cpp

  • Committer: CI bot
  • Author(s): Chris Townsend, Andrea Azzarone, Alfred Neumayer, Brandon Schaefer, Marco Trevisan (Treviño)
  • Date: 2014-07-14 14:30:31 UTC
  • mfrom: (3797.1.35 unity.trusty-7.2.2)
  • Revision ID: ps-jenkins@lists.canonical.com-20140714143031-f5ky7acxlp761352
Prepare for upstream micro-release 7.2.2 that includes fixes for the following bugs:
Bug #607796: Launcher, Window management - Dragging and holding a selection over an entry in the Launcher should spread out windows belonging to that application
Bug #727902: Launcher icon highlighting should not switch off as soon the cursor moves after the app spread appears.
Bug #741869: Unity/compiz intercepts Super and Alt keypresses from grabbed windows like VMs.
Bug #754580: Cannot move tabs between multiple Firefox or Chromium windows while using Unity unless windows are both unmaximized, unminimized, and visible.
Bug #839728: Launcher - dragging a item on top of a launcher tile that is a valid drop receptacle in the Launcher should cause that launcher tile to glow
Bug #924840: Keyboard shortcuts overlay text too long
Bug #1281058: [UIFe] The system shutdowns when multiple accounts are open
Bug #1283775: Launcher: icon pips are not always updated properly
Bug #1304882: [Regression] Launcher doesn't reappear fully after hiding from DND
Bug #1305586: Lock screen is unusable when some windows have a keyboard/mouse grab
Bug #1307738: Lockscreen caps lock icon drawn under text entry, should be a white icon.
Bug #1308288: Lockscreen warning icon has no tooltip
Bug #1308323: Shutdown/reboot/login/logout dialogs not scaled after toggling UI scale Edit
Bug #1308911: Clipboard contents are accessible within lockscreen
Bug #1309739: Unity launcher icon edge illumination is offset
Bug #1310200: Indicators disappear at the panel (clementine, dropbox, skype etc)
Bug #1313280: Fullscreen window set to "Always on Top" in single-monitor will hide the lockscreen
Bug #1316005: Panel shadow appears over full screen applications w/ locally integrated menus enabled
Bug #1317348: Switcher (Alt-Tab) does not respect monitor-defined scaling factor
Bug #1317356: Shortcut hint does not respect monitor scaling factor
Bug #1317869: Keyboard shortcuts overlay does not show up when workspaces are enabled at 1366x768
Bug #1320438: Unity launcher auto hide fails on screen unlock using "Super+L"
Bug #1321043: [regression] lock screen bypass with touchpad Fixes: 607796, 727902, 741869, 754580, 839728, 924840, 1281058, 1283775, 1304882, 1305586, 1307738, 1308288, 1308323, 1308911, 1309739, 1310200, 1313280, 1316005, 1317348, 1317356, 1317869, 1320438, 1321043
Approved by: Marco Trevisan (Treviño)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "SessionView.h"
21
21
#include "SessionButton.h"
22
22
 
23
 
#include <Nux/VLayout.h>
24
23
#include <UnityCore/GLibWrapper.h>
25
24
#include <glib/gi18n-lib.h>
26
25
 
 
26
#include "unity-shared/RawPixel.h"
 
27
 
27
28
namespace unity
28
29
{
29
30
namespace session
31
32
 
32
33
namespace style
33
34
{
34
 
  const std::string FONT = "Ubuntu Light";
35
 
  const std::string TITLE_FONT = FONT+" 15";
36
 
  const std::string SUBTITLE_FONT = FONT+" 12";
 
35
  std::string const FONT = "Ubuntu Light";
 
36
  std::string const TITLE_FONT = FONT+" 15";
 
37
  std::string const SUBTITLE_FONT = FONT+" 12";
37
38
 
38
 
  const unsigned LEFT_RIGHT_PADDING = 30;
39
 
  const unsigned TOP_PADDING = 19;
40
 
  const unsigned BOTTOM_PADDING = 12;
41
 
  const unsigned MAIN_SPACE = 10;
42
 
  const unsigned BUTTONS_SPACE = 20;
 
39
  RawPixel const LEFT_RIGHT_PADDING = 30_em;
 
40
  RawPixel const TOP_PADDING        = 19_em;
 
41
  RawPixel const BOTTOM_PADDING     = 12_em;
 
42
  RawPixel const MAIN_SPACE         = 10_em;
 
43
  RawPixel const BUTTONS_SPACE      = 20_em;
43
44
}
44
45
 
45
46
NUX_IMPLEMENT_OBJECT_TYPE(View);
51
52
  , key_focus_area_(this)
52
53
{
53
54
  closable = true;
54
 
  auto main_layout = new nux::VLayout();
55
 
  main_layout->SetTopAndBottomPadding(style::TOP_PADDING, style::BOTTOM_PADDING);
56
 
  main_layout->SetLeftAndRightPadding(style::LEFT_RIGHT_PADDING);
57
 
  main_layout->SetSpaceBetweenChildren(style::MAIN_SPACE);
58
 
  SetLayout(main_layout);
 
55
  main_layout_ = new nux::VLayout();
 
56
  SetLayout(main_layout_);
59
57
 
60
58
  title_ = new StaticCairoText("");
61
59
  title_->SetFont(style::TITLE_FONT);
62
60
  title_->SetTextAlignment(StaticCairoText::AlignState::NUX_ALIGN_LEFT);
63
61
  title_->SetInputEventSensitivity(false);
64
62
  title_->SetVisible(false);
65
 
  main_layout->AddView(title_);
 
63
  main_layout_->AddView(title_);
66
64
 
67
65
  subtitle_ = new StaticCairoText("");
68
66
  subtitle_->SetFont(style::SUBTITLE_FONT);
70
68
  subtitle_->SetInputEventSensitivity(false);
71
69
  subtitle_->SetLines(std::numeric_limits<int>::min());
72
70
  subtitle_->SetLineSpacing(2);
73
 
  main_layout->AddView(subtitle_);
 
71
  main_layout_->AddView(subtitle_);
74
72
 
75
73
  buttons_layout_ = new nux::HLayout();
76
 
  buttons_layout_->SetSpaceBetweenChildren(style::BUTTONS_SPACE);
77
 
  main_layout->AddLayout(buttons_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_PERCENTAGE, 0.0f);
 
74
  main_layout_->AddLayout(buttons_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_PERCENTAGE, 0.0f);
78
75
 
79
76
  GetBoundingArea()->mouse_click.connect([this] (int, int, unsigned long, unsigned long) { request_close.emit(); });
80
77
 
81
78
  have_inhibitors.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateText)));
 
79
  manager_->have_other_open_sessions.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateText)));
82
80
 
83
81
  mode.SetSetterFunction([this] (Mode& target, Mode new_mode) {
84
82
    if (new_mode == Mode::SHUTDOWN && !manager_->CanShutdown())
98
96
    Populate();
99
97
  });
100
98
 
 
99
  scale.changed.connect(sigc::hide(sigc::mem_fun(this, &View::UpdateViewSize)));
 
100
 
 
101
  UpdateViewSize();
101
102
  UpdateText();
102
103
  Populate();
103
104
}
104
105
 
 
106
void View::UpdateViewSize()
 
107
{
 
108
  main_layout_->SetTopAndBottomPadding(style::TOP_PADDING.CP(scale()), style::BOTTOM_PADDING.CP(scale()));
 
109
  main_layout_->SetLeftAndRightPadding(style::LEFT_RIGHT_PADDING.CP(scale()));
 
110
  main_layout_->SetSpaceBetweenChildren(style::MAIN_SPACE.CP(scale()));
 
111
 
 
112
  title_->SetScale(scale());
 
113
  subtitle_->SetScale(scale());
 
114
 
 
115
  ReloadCloseButtonTexture();
 
116
 
 
117
  buttons_layout_->SetSpaceBetweenChildren(style::BUTTONS_SPACE.CP(scale()));
 
118
 
 
119
  for (auto* area : buttons_layout_->GetChildren())
 
120
  {
 
121
    auto* button = static_cast<Button*>(area);
 
122
    button->scale = scale();
 
123
  }
 
124
}
 
125
 
105
126
void View::UpdateText()
106
127
{
107
 
  const char* message = nullptr;
 
128
  std::string message;
 
129
  std::string other_users_msg;
108
130
  auto const& real_name = manager_->RealName();
109
131
  auto const& name = (real_name.empty() ? manager_->UserName() : real_name);
110
132
 
 
133
  other_users_msg = _("Other users are logged in. Restarting or shutting down will close their open applications and may cause them to lose work.\n\n");
 
134
 
111
135
  if (mode() == Mode::SHUTDOWN)
112
136
  {
113
137
    title_->SetText(_("Shut Down"));
114
138
    title_->SetVisible(true);
115
139
 
 
140
    if (manager_->have_other_open_sessions())
 
141
    {
 
142
      message += other_users_msg;
 
143
    }
 
144
 
116
145
    if (have_inhibitors())
117
146
    {
118
 
      message = _("Hi %s, you have open files that you might want to save " \
119
 
                  "before shutting down. Are you sure you want to continue?");
 
147
      message += _("Hi %s, you have open files that you might want to save " \
 
148
                   "before shutting down. Are you sure you want to continue?");
120
149
    }
121
150
    else
122
151
    {
123
 
      message = _("Goodbye, %s. Are you sure you want to close all programs " \
124
 
                  "and shut down the computer?");
 
152
      message += _("Goodbye, %s. Are you sure you want to close all programs " \
 
153
                   "and shut down the computer?");
125
154
    }
126
155
  }
127
156
  else if (mode() == Mode::LOGOUT)
144
173
  {
145
174
    title_->SetVisible(false);
146
175
 
 
176
    if (manager_->have_other_open_sessions())
 
177
    {
 
178
      message += other_users_msg;
 
179
    }
 
180
 
147
181
    if (have_inhibitors())
148
182
    {
149
183
      if (buttons_layout_->GetChildren().size() > 3)
150
184
      {
151
185
        // We have enough buttons to show the message without a new line.
152
 
        message = _("Hi %s, you have open files you might want to save. " \
 
186
        message += _("Hi %s, you have open files you might want to save. " \
153
187
                    "Would you like to…");
154
188
      }
155
189
      else
156
190
      {
157
 
        message = _("Hi %s, you have open files you might want to save.\n" \
 
191
        message += _("Hi %s, you have open files you might want to save.\n" \
158
192
                    "Would you like to…");
159
193
      }
160
194
    }
161
195
    else
162
196
    {
163
 
      message = _("Goodbye, %s. Would you like to…");
 
197
      message += _("Goodbye, %s. Would you like to…");
164
198
    }
165
199
  }
166
200
 
167
 
  subtitle_->SetText(glib::String(g_strdup_printf(message, name.c_str())).Str());
 
201
  subtitle_->SetText(glib::String(g_strdup_printf(message.c_str(), name.c_str())).Str());
168
202
}
169
203
 
170
204
void View::Populate()
176
210
  if (mode() == Mode::LOGOUT)
177
211
  {
178
212
    auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION);
 
213
    button->scale = scale();
179
214
    button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen));
180
215
    AddButton(button);
181
216
 
189
224
    if (mode() == Mode::FULL)
190
225
    {
191
226
      auto* button = new Button(Button::Action::LOCK, NUX_TRACKER_LOCATION);
 
227
      button->scale = scale();
192
228
      button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::LockScreen));
193
229
      AddButton(button);
194
230
 
195
231
      if (manager_->CanSuspend())
196
232
      {
197
233
        button = new Button(Button::Action::SUSPEND, NUX_TRACKER_LOCATION);
 
234
        button->scale = scale();
198
235
        button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Suspend));
199
236
        AddButton(button);
200
237
      }
202
239
      if (manager_->CanHibernate())
203
240
      {
204
241
        button = new Button(Button::Action::HIBERNATE, NUX_TRACKER_LOCATION);
 
242
        button->scale = scale();
205
243
        button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Hibernate));
206
244
        AddButton(button);
207
245
      }
210
248
    if (manager_->CanShutdown())
211
249
    {
212
250
      auto *button = new Button(Button::Action::REBOOT, NUX_TRACKER_LOCATION);
 
251
      button->scale = scale();
213
252
      button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Reboot));
214
253
      AddButton(button);
215
254
 
216
255
      button = new Button(Button::Action::SHUTDOWN, NUX_TRACKER_LOCATION);
 
256
      button->scale = scale();
217
257
      button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Shutdown));
218
258
      key_focus_area_ = (mode() == Mode::SHUTDOWN) ? button : key_focus_area_;
219
259
      AddButton(button);
221
261
    else if (mode() == Mode::FULL)
222
262
    {
223
263
      auto* button = new Button(Button::Action::LOGOUT, NUX_TRACKER_LOCATION);
 
264
      button->scale = scale();
224
265
      button->activated.connect(sigc::mem_fun(manager_.get(), &Manager::Logout));
225
266
      AddButton(button);
226
267
    }