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