Merge lp:~woodrow-shen/unity-greeter/fix-hidpi-support into lp:unity-greeter

Proposed by Woodrow Shen on 2014-11-18
Status: Rejected
Rejected by: Robert Ancell on 2015-02-12
Proposed branch: lp:~woodrow-shen/unity-greeter/fix-hidpi-support
Merge into: lp:unity-greeter
Diff against target: 617 lines (+171/-38) (has conflicts)
13 files modified
NEWS (+8/-0)
configure.ac (+4/-0)
debian/changelog (+11/-0)
src/cairo-utils.vala (+27/-0)
src/dash-box.vala (+8/-4)
src/dash-button.vala (+3/-1)
src/dash-entry.vala (+8/-3)
src/greeter-list.vala (+13/-8)
src/list-stack.vala (+2/-1)
src/main-window.vala (+4/-1)
src/menubar.vala (+14/-2)
src/prompt-box.vala (+26/-9)
src/shutdown-dialog.vala (+43/-9)
Text conflict in NEWS
Text conflict in configure.ac
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~woodrow-shen/unity-greeter/fix-hidpi-support
Reviewer Review Type Date Requested Status
Robert Ancell 2014-11-18 Pending
Review via email: mp+242046@code.launchpad.net

Commit message

This patch try to fix the problem that unity-greeter can't scale on a hidpi display.
Currenly the icons on menubar still don't work, and sometimes menuitem may unchanged
unexpectedly.

Description of the change

The fix can scale menubar, prompt-box, and shutdown-dialog box according to gnome hidpi rules from https://wiki.gnome.org/HowDoI/HiDpi. so I just added hidpi checking into cairo-utils for temporary. But icons on menubar seem that it's hard to scale even if I used to re-scale by gtk.image. Besides, the scale factor is fixed to 2 for hidpi condition.

To post a comment you must log in.
Robert Ancell (robert-ancell) wrote :

This branch shows merge conflicts - should this have been proposed to lp:unity-greeter/14.04?

Robert Ancell (robert-ancell) wrote :

In check_hidpi_display you iterate across all the monitors but only check the primary one. Why not just:

screen.get_monitor_geometry(primary, out area)

Robert Ancell (robert-ancell) wrote :

You have a number of cases where you've used an explicit variable type, e.g. "int num_monitor" where you could just use "var num_monitor" instead.

Robert Ancell (robert-ancell) wrote :

You have a lot of hardcoded scaling like:

var hidpi = CairoUtils.check_hidpi_display();
scale = (hidpi) ? 2 : 1;

Why not:
scale = CairoUtils.get_hidpi_scale ()

and just define the 2 once in that function?

Robert Ancell (robert-ancell) wrote :

It otherwise looks pretty good. Thanks Woodrow!

Woodrow Shen (woodrow-shen) wrote :

ok, I will re-modify it and re-send proposal to lp:unity-greeter/14.04. You just reject this merge proposal ?

Robert Ancell (robert-ancell) wrote :

You should update this proposal to apply to trunk and also make one that applies to 14.04 - otherwise users in 15.04 will not have hidpi support. We should also consider making an MP that applies to 14.10. This is easy to do once this is applied to trunk:

$ bzr branch lp:unity-greeter/14.04
$ cd 14.04
$ bzr merge -c <commit> lp:unity-greeter
$ bzr commit
(make merge request)

1207. By Woodrow Shen on 2014-11-20

Use get_hidpi_scale function to replace hard-code.

1208. By Woodrow Shen on 2014-11-21

Fix the some code style.

1209. By Woodrow Shen on 2014-11-21

Fix the correct space number without tab.

Robert Ancell (robert-ancell) wrote :

Rejecting this MP because it's out of sync and according to https://code.launchpad.net/~fourdollars/unity-greeter/add-hidpi-support/+merge/244266 it should be obsolete.

Unmerged revisions

1209. By Woodrow Shen on 2014-11-21

Fix the correct space number without tab.

1208. By Woodrow Shen on 2014-11-21

Fix the some code style.

1207. By Woodrow Shen on 2014-11-20

Use get_hidpi_scale function to replace hard-code.

1206. By Woodrow Shen on 2014-11-18

This patch try to fix the problem that unity-greeter can't scale on a hidpi display.
Currenly the icons on menubar still don't work, and sometimes menuitem may unchanged
unexpectedly.

1205. By Robert Ancell on 2014-04-30

Releasing 14.04.10

1204. By Robert Ancell on 2014-04-30

Require user to acknowledge messages after last prompt

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2014-08-21 21:50:24 +0000
3+++ NEWS 2014-11-21 06:18:52 +0000
4@@ -1,3 +1,4 @@
5+<<<<<<< TREE
6 Overview of changes in unity-greeter 14.10.2
7
8 - Switch the screen reader keyboard shortcut to be the same as the default
9@@ -12,6 +13,13 @@
10 - Require user to acknowledge messages received after authentication is
11 complete, for example if their password is about to expire.
12
13+=======
14+Overview of changes in unity-greeter 14.04.10
15+
16+ - Require user to acknowledge messages received after authentication is
17+ complete, for example if their password is about to expire.
18+
19+>>>>>>> MERGE-SOURCE
20 Overview of changes in unity-greeter 14.04.9
21
22 - Correctly handle SIGTERM and quit cleanly. We were previously not stopping
23
24=== modified file 'configure.ac'
25--- configure.ac 2014-11-04 02:49:30 +0000
26+++ configure.ac 2014-11-21 06:18:52 +0000
27@@ -2,7 +2,11 @@
28
29 dnl Process this file with autoconf to produce a configure script.
30
31+<<<<<<< TREE
32 AC_INIT(unity-greeter, 14.10.2)
33+=======
34+AC_INIT(unity-greeter, 14.04.10)
35+>>>>>>> MERGE-SOURCE
36 AC_CONFIG_MACRO_DIR(m4)
37 AM_INIT_AUTOMAKE
38 AM_PROG_CC_C_O
39
40=== modified file 'debian/changelog'
41--- debian/changelog 2014-08-21 21:50:24 +0000
42+++ debian/changelog 2014-11-21 06:18:52 +0000
43@@ -1,3 +1,4 @@
44+<<<<<<< TREE
45 unity-greeter (14.10.2-0ubuntu1) utopic; urgency=medium
46
47 * New upstream release:
48@@ -27,6 +28,16 @@
49
50 -- Dimitri John Ledkov <xnox@ubuntu.com> Thu, 24 Apr 2014 00:23:42 +0100
51
52+=======
53+unity-greeter (14.04.10-0ubuntu1) trusty; urgency=medium
54+
55+ * New upstream release:
56+ - Require user to acknowledge messages received after authentication is
57+ complete, for example if their password is about to expire. (LP: #1304866)
58+
59+ -- Robert Ancell <robert.ancell@canonical.com> Wed, 30 Apr 2014 15:33:19 +1200
60+
61+>>>>>>> MERGE-SOURCE
62 unity-greeter (14.04.9-0ubuntu1) trusty; urgency=medium
63
64 * New upstream release:
65
66=== modified file 'src/cairo-utils.vala'
67--- src/cairo-utils.vala 2014-04-30 00:13:06 +0000
68+++ src/cairo-utils.vala 2014-11-21 06:18:52 +0000
69@@ -18,9 +18,36 @@
70 * Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
71 */
72
73+public const int HIDPI_SCALE = 2;
74+
75 namespace CairoUtils
76 {
77
78+public bool check_hidpi_display ()
79+{
80+ var screen = Gdk.Screen.get_default();
81+ var primary = screen.get_primary_monitor();
82+
83+ Gdk.Rectangle area;
84+ screen.get_monitor_geometry(primary, out area);
85+
86+ var diagonal = Math.sqrt (area.width * area.width + area.height * area.height);
87+
88+ var width_mm = screen.get_monitor_width_mm(primary);
89+ var height_mm = screen.get_monitor_height_mm(primary);
90+
91+ var diagonal_mm = Math.sqrt (width_mm * width_mm + height_mm * height_mm);
92+
93+ var ppi = (int) (diagonal * 25.4 / diagonal_mm);
94+
95+ return (ppi >= 192) && (area.height >= 1200);
96+}
97+
98+public int get_hidpi_scale ()
99+{
100+ return check_hidpi_display() ? HIDPI_SCALE : 1;
101+}
102+
103 public void rounded_rectangle (Cairo.Context c, double x, double y,
104 double width, double height, double radius)
105 {
106
107=== modified file 'src/dash-box.vala'
108--- src/dash-box.vala 2013-11-12 03:27:13 +0000
109+++ src/dash-box.vala 2014-11-21 06:18:52 +0000
110@@ -156,8 +156,11 @@
111 }
112 else
113 {
114- min = grid_size * GreeterList.DEFAULT_BOX_HEIGHT - GreeterList.BORDER * 2;
115- nat = grid_size * GreeterList.DEFAULT_BOX_HEIGHT - GreeterList.BORDER * 2;
116+ var scale = CairoUtils.get_hidpi_scale();
117+ min = grid_size * GreeterList.DEFAULT_BOX_HEIGHT * scale - GreeterList.BORDER *
118+ scale * 2;
119+ nat = grid_size * GreeterList.DEFAULT_BOX_HEIGHT * scale - GreeterList.BORDER *
120+ scale * 2;
121 }
122 }
123 else
124@@ -175,8 +178,9 @@
125
126 public override void get_preferred_width (out int min, out int nat)
127 {
128- min = grid_size * GreeterList.BOX_WIDTH - GreeterList.BORDER * 2;
129- nat = grid_size * GreeterList.BOX_WIDTH - GreeterList.BORDER * 2;
130+ var scale = CairoUtils.get_hidpi_scale();
131+ min = grid_size * GreeterList.BOX_WIDTH * scale - GreeterList.BORDER * scale * 2;
132+ nat = grid_size * GreeterList.BOX_WIDTH * scale - GreeterList.BORDER * scale * 2;
133 }
134
135 public override bool draw (Cairo.Context c)
136
137=== modified file 'src/dash-button.vala'
138--- src/dash-button.vala 2013-01-04 16:56:55 +0000
139+++ src/dash-button.vala 2014-11-21 06:18:52 +0000
140@@ -29,7 +29,9 @@
141 set
142 {
143 _text = value;
144- text_label.set_markup ("<span font=\"Ubuntu 13\">%s</span>".printf (value));
145+ var font_size = 13 * CairoUtils.get_hidpi_scale();
146+ var font = "<span font=\"Ubuntu %d\">%s</span>".printf (font_size, value);
147+ text_label.set_markup (font.printf (value));
148 }
149 }
150
151
152=== modified file 'src/dash-entry.vala'
153--- src/dash-entry.vala 2013-02-20 16:17:42 +0000
154+++ src/dash-entry.vala 2014-11-21 06:18:52 +0000
155@@ -23,7 +23,6 @@
156
157 public class DashEntry : Gtk.Entry, Fadable
158 {
159- public static string font = "Ubuntu 14";
160 public signal void respond ();
161
162 public string constant_placeholder_text { get; set; }
163@@ -73,7 +72,10 @@
164 }
165 }
166
167- override_font (Pango.FontDescription.from_string (font));
168+ var font_size = 14 * CairoUtils.get_hidpi_scale();
169+ var set_font = "Ubuntu " + font_size.to_string();
170+
171+ override_font (Pango.FontDescription.from_string (set_font));
172
173 var style_ctx = get_style_context ();
174
175@@ -187,7 +189,10 @@
176
177 /* Draw text */
178 var layout = create_pango_layout (constant_placeholder_text);
179- layout.set_font_description (Pango.FontDescription.from_string ("Ubuntu 13"));
180+ var font_size = 13 * CairoUtils.get_hidpi_scale();
181+ var set_font = "Ubuntu " + font_size.to_string();
182+
183+ layout.set_font_description (Pango.FontDescription.from_string (set_font));
184 Pango.cairo_show_layout (c, layout);
185
186 c.restore ();
187
188=== modified file 'src/greeter-list.vala'
189--- src/greeter-list.vala 2014-04-30 00:11:07 +0000
190+++ src/greeter-list.vala 2014-11-21 06:18:52 +0000
191@@ -92,6 +92,7 @@
192 private Gtk.Fixed fixed;
193 public DashBox greeter_box;
194 private int cached_box_height = -1;
195+ private int scale;
196
197 protected enum Mode
198 {
199@@ -118,7 +119,7 @@
200 {
201 /* First, get grid row number as if menubar weren't there */
202 var row = (MainWindow.MENUBAR_HEIGHT + get_allocated_height ()) / grid_size;
203- row = row - DEFAULT_BOX_HEIGHT; /* and no default dash box */
204+ row = row - (DEFAULT_BOX_HEIGHT * scale); /* and no default dash box */
205 row = row / 2; /* and in the middle */
206 /* Now calculate y pixel spot keeping in mind menubar's allocation */
207 return row * grid_size - MainWindow.MENUBAR_HEIGHT;
208@@ -193,6 +194,8 @@
209 {
210 debug ("Error getting session bus: %s", e.message);
211 }
212+
213+ scale = CairoUtils.get_hidpi_scale();
214 }
215
216 private void on_bus_acquired (Object? obj, AsyncResult res)
217@@ -219,8 +222,8 @@
218
219 public override void get_preferred_width (out int min, out int nat)
220 {
221- min = BOX_WIDTH * grid_size;
222- nat = BOX_WIDTH * grid_size;
223+ min = BOX_WIDTH * scale * grid_size;
224+ nat = BOX_WIDTH * scale * grid_size;
225 }
226
227 public override void get_preferred_height (out int min, out int nat)
228@@ -390,7 +393,8 @@
229 protected void add_entry (PromptBox entry)
230 {
231 entry.expand = true;
232- entry.set_size_request (grid_size * BOX_WIDTH - BORDER * 2, -1);
233+
234+ entry.set_size_request (grid_size * (BOX_WIDTH * scale) - (BORDER * scale) * 2, -1);
235 add_with_class (entry);
236
237 insert_entry (entry);
238@@ -493,12 +497,12 @@
239
240 protected int get_greeter_box_x ()
241 {
242- return box_x + BORDER;
243+ return box_x + (BORDER * scale);
244 }
245
246 protected int get_greeter_box_y ()
247 {
248- return box_y + BORDER;
249+ return box_y + (BORDER * scale);
250 }
251
252 protected virtual int get_position_y (double position)
253@@ -534,7 +538,7 @@
254 get_allocation (out allocation);
255
256 var child_allocation = Gtk.Allocation ();
257- child_allocation.width = grid_size * BOX_WIDTH - BORDER * 2;
258+ child_allocation.width = grid_size * (BOX_WIDTH * scale) - (BORDER * scale) * 2;
259 entry.get_preferred_height_for_width (child_allocation.width, null, out child_allocation.height);
260 child_allocation.x = allocation.x + get_greeter_box_x ();
261 child_allocation.y = allocation.y + get_position_y (position);
262@@ -735,7 +739,8 @@
263 c.save ();
264 c.push_group ();
265
266- c.rectangle (get_greeter_box_x (), get_greeter_box_y () - n_above * grid_size, grid_size * BOX_WIDTH - BORDER * 2, grid_size * (n_above + n_below + get_greeter_box_height_grids ()));
267+ c.rectangle (get_greeter_box_x (), get_greeter_box_y () - n_above * grid_size, grid_size
268+ * (BOX_WIDTH * scale)- (BORDER * scale) * 2, grid_size * (n_above + n_below + get_greeter_box_height_grids ()));
269 c.clip ();
270
271 foreach (var child in fixed.get_children ())
272
273=== modified file 'src/list-stack.vala'
274--- src/list-stack.vala 2012-08-27 22:30:33 +0000
275+++ src/list-stack.vala 2014-11-21 06:18:52 +0000
276@@ -32,7 +32,8 @@
277
278 construct
279 {
280- width = grid_size * GreeterList.BOX_WIDTH;
281+ var scale = CairoUtils.get_hidpi_scale();
282+ width = grid_size * GreeterList.BOX_WIDTH * scale;
283 }
284
285 public GreeterList? top ()
286
287=== modified file 'src/main-window.vala'
288--- src/main-window.vala 2014-03-26 21:25:01 +0000
289+++ src/main-window.vala 2014-11-21 06:18:52 +0000
290@@ -88,7 +88,10 @@
291 {
292 debug ("Internal error loading menubox style: %s", e.message);
293 }
294- menubox.set_size_request (-1, MENUBAR_HEIGHT);
295+
296+ var scale = CairoUtils.get_hidpi_scale();
297+
298+ menubox.set_size_request (-1, MENUBAR_HEIGHT * scale);
299 menubox.show ();
300 menualign.show ();
301 menubox.add (menualign);
302
303=== modified file 'src/menubar.vala'
304--- src/menubar.vala 2014-08-21 04:39:56 +0000
305+++ src/menubar.vala 2014-11-21 06:18:52 +0000
306@@ -115,6 +115,7 @@
307 private Pid keyboard_pid = 0;
308 private Pid reader_pid = 0;
309 private Gtk.CheckMenuItem onscreen_keyboard_item;
310+ private int scale;
311
312 construct
313 {
314@@ -122,6 +123,8 @@
315
316 pack_direction = Gtk.PackDirection.RTL;
317
318+ scale = CairoUtils.get_hidpi_scale();
319+
320 if (UGSettings.get_boolean (UGSettings.KEY_SHOW_HOSTNAME))
321 {
322 var label = new Gtk.Label (Posix.utsname ().nodename);
323@@ -137,6 +140,8 @@
324 label.ensure_style ();
325 var fg = label.get_style_context ().get_color (Gtk.StateFlags.NORMAL);
326 label.override_color (Gtk.StateFlags.INSENSITIVE, fg);
327+ var font = 12 * scale;
328+ label.override_font (Pango.FontDescription.from_string (font.to_string()));
329 }
330
331 /* Prevent dragging the window by the menubar */
332@@ -175,8 +180,8 @@
333
334 public override void get_preferred_height (out int min, out int nat)
335 {
336- min = HEIGHT;
337- nat = HEIGHT;
338+ min = HEIGHT * scale;
339+ nat = HEIGHT * scale;
340 }
341
342 private void greeter_set_env (string key, string val)
343@@ -218,17 +223,21 @@
344 a11y_item.show ();
345 a11y_item.set_submenu (new Gtk.Menu () as Gtk.Widget);
346 onscreen_keyboard_item = new Gtk.CheckMenuItem.with_label (_("Onscreen keyboard"));
347+ var font = 12 * scale;
348+ onscreen_keyboard_item.override_font (Pango.FontDescription.from_string (font.to_string()));
349 onscreen_keyboard_item.toggled.connect (keyboard_toggled_cb);
350 onscreen_keyboard_item.show ();
351 unowned Gtk.Menu submenu = a11y_item.submenu;
352 submenu.append (onscreen_keyboard_item);
353 high_contrast_item = new Gtk.CheckMenuItem.with_label (_("High Contrast"));
354+ high_contrast_item.override_font (Pango.FontDescription.from_string (font.to_string()));
355 high_contrast_item.toggled.connect (high_contrast_toggled_cb);
356 high_contrast_item.add_accelerator ("activate", accel_group, Gdk.Key.h, Gdk.ModifierType.CONTROL_MASK, Gtk.AccelFlags.VISIBLE);
357 high_contrast_item.show ();
358 submenu.append (high_contrast_item);
359 high_contrast_item.set_active (UGSettings.get_boolean (UGSettings.KEY_HIGH_CONTRAST));
360 var item = new Gtk.CheckMenuItem.with_label (_("Screen Reader"));
361+ item.override_font (Pango.FontDescription.from_string (font.to_string()));
362 item.toggled.connect (screen_reader_toggled_cb);
363 item.add_accelerator ("activate", accel_group, Gdk.Key.s, Gdk.ModifierType.SUPER_MASK | Gdk.ModifierType.MOD1_MASK, Gtk.AccelFlags.VISIBLE);
364 item.show ();
365@@ -527,6 +536,9 @@
366 break;
367
368 var menuitem = (IndicatorMenuItem) child;
369+ var font = 12 * scale;
370+ menuitem.override_font (Pango.FontDescription.from_string (font.to_string()));
371+ menuitem.entry.label.override_font (Pango.FontDescription.from_string (font.to_string()));
372 var child_object = get_indicator_object_from_entry (menuitem.entry);
373 var child_index = get_indicator_index (child_object);
374 if (child_index > index)
375
376=== modified file 'src/prompt-box.vala'
377--- src/prompt-box.vala 2013-01-01 20:26:59 +0000
378+++ src/prompt-box.vala 2014-11-21 06:18:52 +0000
379@@ -71,6 +71,9 @@
380 protected static const int COL_ENTRIES_END = 1;
381 protected static const int COL_ENTRIES_WIDTH = 1;
382
383+ protected static const int MSG_FONT_SIZE = 10;
384+ protected static const int LAB_FONT_SIZE = 13;
385+
386 protected int start_row;
387 protected int last_row;
388
389@@ -87,12 +90,16 @@
390 Object (id: id);
391 }
392
393+ private int scale;
394+
395 construct
396 {
397 set_start_row ();
398 reset_last_row ();
399 expand = true;
400
401+ scale = CairoUtils.get_hidpi_scale();
402+
403 fixed = new Gtk.Fixed ();
404 fixed.show ();
405 add (fixed);
406@@ -100,7 +107,7 @@
407 box_grid = new Gtk.Grid ();
408 box_grid.column_spacing = 4;
409 box_grid.row_spacing = 3;
410- box_grid.margin_top = GreeterList.BORDER;
411+ box_grid.margin_top = GreeterList.BORDER * scale;
412 box_grid.margin_bottom = 6;
413 box_grid.expand = true;
414
415@@ -171,8 +178,11 @@
416 name_grid.column_spacing = 4;
417 name_grid.hexpand = true;
418
419+ int font_size = LAB_FONT_SIZE * scale;
420+ string font = "Ubuntu " + font_size.to_string();
421+
422 name_label = new FadingLabel ("");
423- name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
424+ name_label.override_font (Pango.FontDescription.from_string (font));
425 name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
426 name_label.valign = Gtk.Align.START;
427 name_label.vexpand = true;
428@@ -235,8 +245,11 @@
429 var small_name_grid = new Gtk.Grid ();
430 small_name_grid.column_spacing = 4;
431
432+ var font_size = LAB_FONT_SIZE * scale;
433+ var font = "Ubuntu " + font_size.to_string();
434+
435 small_name_label = new FadingLabel ("");
436- small_name_label.override_font (Pango.FontDescription.from_string ("Ubuntu 13"));
437+ small_name_label.override_font (Pango.FontDescription.from_string (font));
438 small_name_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
439 small_name_label.yalign = 0.5f;
440 small_name_label.xalign = 0.0f;
441@@ -281,8 +294,8 @@
442 public override void get_preferred_height (out int min, out int nat)
443 {
444 base.get_preferred_height (out min, out nat);
445- min = round_to_grid (min + GreeterList.BORDER * 2) - GreeterList.BORDER * 2;
446- nat = round_to_grid (nat + GreeterList.BORDER * 2) - GreeterList.BORDER * 2;
447+ min = round_to_grid (min + GreeterList.BORDER * scale * 2) - GreeterList.BORDER * scale * 2;
448+ nat = round_to_grid (nat + GreeterList.BORDER * scale * 2) - GreeterList.BORDER * scale * 2;
449 }
450
451 public void set_zone (Gtk.Widget zone)
452@@ -435,8 +448,10 @@
453 public void add_message (string text, bool is_error)
454 {
455 var label = new FadingLabel (text);
456+ var font_size = MSG_FONT_SIZE * scale;
457+ var font = "Ubuntu " + font_size.to_string();
458
459- label.override_font (Pango.FontDescription.from_string ("Ubuntu 10"));
460+ label.override_font (Pango.FontDescription.from_string (font));
461
462 Gdk.RGBA color = { 1.0f, 1.0f, 1.0f, 1.0f };
463 if (is_error)
464@@ -514,7 +529,9 @@
465
466 combo.get_style_context ().add_class ("lightdm-combo");
467 combo.get_child ().get_style_context ().add_class ("lightdm-combo");
468- combo.get_child ().override_font (Pango.FontDescription.from_string (DashEntry.font));
469+ var font_size = 14 * CairoUtils.get_hidpi_scale();
470+ var font = "Ubuntu " + font_size.to_string();
471+ combo.get_child ().override_font (Pango.FontDescription.from_string (font));
472
473 attach_item (combo, false);
474
475@@ -644,13 +661,13 @@
476
477 public override void get_preferred_width (out int min, out int nat)
478 {
479- min = WIDTH;
480+ min = WIDTH * CairoUtils.get_hidpi_scale();
481 nat = min;
482 }
483
484 public override void get_preferred_height (out int min, out int nat)
485 {
486- min = HEIGHT;
487+ min = HEIGHT * CairoUtils.get_hidpi_scale();
488 nat = min;
489 }
490
491
492=== modified file 'src/shutdown-dialog.vala'
493--- src/shutdown-dialog.vala 2014-03-26 20:46:06 +0000
494+++ src/shutdown-dialog.vala 2014-11-21 06:18:52 +0000
495@@ -56,6 +56,7 @@
496
497 private AnimateTimer animation;
498 private bool closing = false;
499+ private int scale;
500
501
502 public ShutdownDialog (ShutdownDialogType type, Background bg)
503@@ -76,14 +77,16 @@
504 });
505 add (monitor_events);
506
507- vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
508+ scale = CairoUtils.get_hidpi_scale();
509+
510+ vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 10 * scale);
511 vbox.visible = true;
512
513 vbox.margin = BORDER_INTERNAL_SIZE;
514- vbox.margin_top += 9;
515- vbox.margin_left += 20;
516- vbox.margin_right += 20;
517- vbox.margin_bottom += 2;
518+ vbox.margin_top += 9 * scale ;
519+ vbox.margin_left += 20 * scale;
520+ vbox.margin_right += 20 * scale;
521+ vbox.margin_bottom += 2 * scale;
522
523 // This event box consumes the click events inside the vbox
524 vbox_events = new Gtk.EventBox();
525@@ -104,7 +107,9 @@
526 {
527 var title_label = new Gtk.Label (_("Shut Down"));
528 title_label.visible = true;
529- title_label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 15"));
530+ var font_size = 15 * scale;
531+ var font = "Ubuntu Light " + font_size.to_string();
532+ title_label.override_font (Pango.FontDescription.from_string (font));
533 title_label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
534 title_label.set_alignment (0.0f, 0.5f);
535 vbox.pack_start (title_label, false, false, 0);
536@@ -138,13 +143,15 @@
537
538 var label = new Gtk.Label (text);
539 label.set_line_wrap (true);
540- label.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));
541+ var font_size = 12 * scale;
542+ var font = "Ubuntu Light " + font_size.to_string();
543+ label.override_font (Pango.FontDescription.from_string (font));
544 label.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 1.0f });
545 label.set_alignment (0.0f, 0.5f);
546 label.visible = true;
547 vbox.pack_start (label, false, false, 0);
548
549- button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
550+ button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20 * 2);
551 button_box.visible = true;
552 vbox.pack_start (button_box, false, false, 0);
553
554@@ -541,6 +548,7 @@
555 private string? active_filename;
556 private Gtk.Image i;
557 private Gtk.Label? l;
558+ private int scale;
559
560 public DialogButton (string inactive_filename, string focused_filename, string? active_filename, Gtk.Label? label = null)
561 {
562@@ -550,6 +558,11 @@
563 relief = Gtk.ReliefStyle.NONE;
564 focus_on_click = false;
565 i = new Gtk.Image.from_file (inactive_filename);
566+ scale = CairoUtils.get_hidpi_scale();
567+ int h = i.pixbuf.height;
568+ int w = i.pixbuf.width;
569+ var pixbuf = i.pixbuf.scale_simple(h * scale, w * scale, Gdk.InterpType.BILINEAR);
570+ i.set_from_pixbuf(pixbuf);
571 i.visible = true;
572 add (i);
573
574@@ -558,7 +571,9 @@
575 if (l != null)
576 {
577 l.visible = true;
578- l.override_font (Pango.FontDescription.from_string ("Ubuntu Light 12"));
579+ var font_size = 12 * scale;
580+ var font = "Ubuntu Light " + font_size.to_string();
581+ l.override_font (Pango.FontDescription.from_string (font));
582 l.override_color (Gtk.StateFlags.NORMAL, { 1.0f, 1.0f, 1.0f, 0.0f });
583 l.override_color (Gtk.StateFlags.FOCUSED, { 1.0f, 1.0f, 1.0f, 1.0f });
584 l.override_color (Gtk.StateFlags.ACTIVE, { 1.0f, 1.0f, 1.0f, 1.0f });
585@@ -605,13 +620,32 @@
586 (new_flags & Gtk.StateFlags.FOCUSED) != 0)
587 {
588 if ((new_flags & Gtk.StateFlags.ACTIVE) != 0 && active_filename != null)
589+ {
590 i.set_from_file (active_filename);
591+
592+ int h = i.pixbuf.height;
593+ int w = i.pixbuf.width;
594+ var pixbuf = i.pixbuf.scale_simple(h * scale, w * scale, Gdk.InterpType.BILINEAR);
595+ i.set_from_pixbuf(pixbuf);
596+ }
597 else
598+ {
599 i.set_from_file (focused_filename);
600+
601+ int h = i.pixbuf.height;
602+ int w = i.pixbuf.width;
603+ var pixbuf = i.pixbuf.scale_simple(h * scale, w * scale, Gdk.InterpType.BILINEAR);
604+ i.set_from_pixbuf(pixbuf);
605+ }
606 }
607 else
608 {
609 i.set_from_file (inactive_filename);
610+
611+ int h = i.pixbuf.height;
612+ int w = i.pixbuf.width;
613+ var pixbuf = i.pixbuf.scale_simple(h * scale, w * scale, Gdk.InterpType.BILINEAR);
614+ i.set_from_pixbuf(pixbuf);
615 }
616
617 if (l != null)

Subscribers

People subscribed via source and target branches