Merge lp:~elementary-pantheon/switchboard-plug-about/oem-support into lp:~elementary-apps/switchboard-plug-about/trunk

Proposed by Danielle Foré
Status: Needs review
Proposed branch: lp:~elementary-pantheon/switchboard-plug-about/oem-support
Merge into: lp:~elementary-apps/switchboard-plug-about/trunk
Diff against target: 246 lines (+121/-68)
1 file modified
src/Plug.vala (+121/-68)
To merge this branch: bzr merge lp:~elementary-pantheon/switchboard-plug-about/oem-support
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+322590@code.launchpad.net

Description of the change

Adds support for oem.conf

To post a comment you must log in.

Unmerged revisions

446. By Danielle Foré

make icon fall back

445. By Danielle Foré

mess about with grids

444. By Corentin Noël

Enable OEM basic inclusion

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Plug.vala'
--- src/Plug.vala 2017-04-09 21:01:56 +0000
+++ src/Plug.vala 2017-04-14 19:25:56 +0000
@@ -26,6 +26,12 @@
26 private string memory;26 private string memory;
27 private string graphics;27 private string graphics;
28 private string hdd;28 private string hdd;
29 private bool oem_enabled;
30 private string manufacturer_name;
31 private string manufacturer_icon_path;
32 private string manufacturer_support_url;
33 private string product_name;
34 private string product_version;
29 private Gtk.Label based_off;35 private Gtk.Label based_off;
3036
3137
@@ -214,6 +220,35 @@
214 critical (e.message);220 critical (e.message);
215 hdd = _("Unknown");221 hdd = _("Unknown");
216 }222 }
223
224 try {
225 var oem_file = new KeyFile ();
226 oem_file.load_from_file ("/etc/oem.conf", KeyFileFlags.NONE);
227 // Assume we get the manufacturer name
228 manufacturer_name = oem_file.get_string ("OEM", "MANUFACTURER");
229
230 // We need to check if the key is here because get_string throws an error if the key isn't available.
231 if (oem_file.has_key ("OEM", "PRODUCT")) {
232 product_name = oem_file.get_string ("OEM", "PRODUCT");
233 }
234
235 if (oem_file.has_key ("OEM", "VERSION")) {
236 product_version = oem_file.get_string ("OEM", "VERSION");
237 }
238
239 if (oem_file.has_key ("OEM", "LOGO")) {
240 manufacturer_icon_path = oem_file.get_string ("OEM", "LOGO");
241 }
242
243 if (oem_file.has_key ("OEM", "URL")) {
244 manufacturer_support_url = oem_file.get_string ("OEM", "URL");
245 }
246
247 oem_enabled = true;
248 } catch (Error e) {
249 debug (e.message);
250 oem_enabled = false;
251 }
217 }252 }
218253
219 private string get_graphics_from_string(string graphics) {254 private string get_graphics_from_string(string graphics) {
@@ -241,70 +276,37 @@
241 private void setup_ui () {276 private void setup_ui () {
242 // Create the section about elementary OS277 // Create the section about elementary OS
243 var logo = new Gtk.Image.from_icon_name ("distributor-logo", Gtk.icon_size_register ("LOGO", 128, 128));278 var logo = new Gtk.Image.from_icon_name ("distributor-logo", Gtk.icon_size_register ("LOGO", 128, 128));
244 logo.halign = Gtk.Align.END;279 logo.hexpand = true;
245280
246 var title = new Gtk.Label (os);281 var title = new Gtk.Label (os);
247 title.get_style_context ().add_class ("h2");282 title.get_style_context ().add_class ("h2");
283 title.xalign = 1;
248 title.set_selectable (true);284 title.set_selectable (true);
249285
250 var arch_name = new Gtk.Label ("(%s)".printf (arch));286 var arch_name = new Gtk.Label ("(%s)".printf (arch));
251 arch_name.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);287 arch_name.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
252 arch_name.valign = Gtk.Align.CENTER;288 arch_name.xalign = 0;
253
254 var title_grid = new Gtk.Grid ();
255 title_grid.column_spacing = 6;
256 title_grid.valign = Gtk.Align.END;
257 title_grid.halign = Gtk.Align.START;
258 title_grid.vexpand = true;
259 title_grid.add (title);
260 title_grid.add (arch_name);
261289
262 if (upstream_release != null) {290 if (upstream_release != null) {
263 based_off = new Gtk.Label (_("Built on %s").printf (upstream_release));291 based_off = new Gtk.Label (_("Built on %s").printf (upstream_release));
264 based_off.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);292 based_off.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
265 based_off.halign = Gtk.Align.START;
266 based_off.set_selectable (true);293 based_off.set_selectable (true);
267 }294 }
268295
269 var website_label = new Gtk.LinkButton.with_label (website_url, _("Website"));296 var website_label = new Gtk.LinkButton.with_label (website_url, _("Website"));
270 website_label.halign = Gtk.Align.START;297 website_label.margin_top = 12;
271 website_label.valign = Gtk.Align.START;298
272 website_label.vexpand = true;299 var processor_info = new Gtk.Label (_("%s processor").printf (processor));
273300 processor_info.margin_top = 12;
274 var hardware_title = new Gtk.Label (null);
275 hardware_title.set_label (_("Hardware"));
276 hardware_title.get_style_context ().add_class ("h4");
277 hardware_title.halign = Gtk.Align.START;
278 hardware_title.margin_top = 24;
279
280 var processor_label = new Gtk.Label (_("Processor:"));
281 processor_label.xalign = 1;
282
283 var memory_label = new Gtk.Label (_("Memory:"));
284 memory_label.xalign = 1;
285
286 var graphics_label = new Gtk.Label (_("Graphics:"));
287 graphics_label.xalign = 1;
288
289 var hdd_label = new Gtk.Label (_("Storage:"));
290 hdd_label.xalign = 1;
291
292 var processor_info = new Gtk.Label (processor);
293 processor_info.xalign = 0;
294 processor_info.set_selectable (true);301 processor_info.set_selectable (true);
295 processor_info.set_line_wrap (false);
296302
297 var memory_info = new Gtk.Label (memory);303 var memory_info = new Gtk.Label (_("%s memory").printf (memory));
298 memory_info.xalign = 0;
299 memory_info.set_selectable (true);304 memory_info.set_selectable (true);
300305
301 var graphics_info = new Gtk.Label (graphics);306 var graphics_info = new Gtk.Label (_("%s graphics").printf (graphics));
302 graphics_info.xalign = 0;
303 graphics_info.set_selectable (true);307 graphics_info.set_selectable (true);
304 graphics_info.set_line_wrap (false);
305308
306 var hdd_info = new Gtk.Label (hdd);309 var hdd_info = new Gtk.Label (_("%s storage").printf (hdd));
307 hdd_info.xalign = 0;
308 hdd_info.set_selectable (true);310 hdd_info.set_selectable (true);
309311
310 var help_button = new Gtk.Button.with_label ("?");312 var help_button = new Gtk.Button.with_label ("?");
@@ -367,36 +369,87 @@
367 button_grid.add (bug_button);369 button_grid.add (bug_button);
368 button_grid.add (update_button);370 button_grid.add (update_button);
369371
370 var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);372 var button_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
371 size_group.add_widget (settings_restore_button);373 button_size_group.add_widget (settings_restore_button);
372 size_group.add_widget (translate_button);374 button_size_group.add_widget (translate_button);
373 size_group.add_widget (bug_button);375 button_size_group.add_widget (bug_button);
374 size_group.add_widget (update_button);376 button_size_group.add_widget (update_button);
375377
376 // Fit everything in a grid378 var software_grid = new Gtk.Grid ();
379 software_grid.column_spacing = 6;
380 software_grid.row_spacing = 6;
381 software_grid.attach (logo, 0, 0, 2, 1);
382 software_grid.attach (title, 0, 1, 1, 1);
383 software_grid.attach (arch_name, 1, 1, 1, 1);
384
385 if (upstream_release != null) {
386 software_grid.attach (based_off, 0, 2, 2, 1);
387 }
388
389 software_grid.attach (website_label, 0, 3, 2, 1);
390
391 var manufacturer_logo = new Gtk.Image ();
392 manufacturer_logo.pixel_size = 128;
393 manufacturer_logo.icon_name = "computer";
394
395 var hardware_grid = new Gtk.Grid ();
396 hardware_grid.column_spacing = 6;
397 hardware_grid.row_spacing = 6;
398 hardware_grid.attach (manufacturer_logo, 0, 0, 2, 1);
399 hardware_grid.attach (processor_info, 0, 3, 2, 1);
400 hardware_grid.attach (graphics_info, 0, 4, 2, 1);
401 hardware_grid.attach (memory_info, 0, 5, 2, 1);
402 hardware_grid.attach (hdd_info, 0, 6, 2, 1);
403
404 var description_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
405 description_size_group.add_widget (hardware_grid);
406 description_size_group.add_widget (software_grid);
407
377 var description_grid = new Gtk.Grid ();408 var description_grid = new Gtk.Grid ();
378 description_grid.halign = Gtk.Align.CENTER;409 description_grid.halign = Gtk.Align.CENTER;
379 description_grid.valign = Gtk.Align.CENTER;410 description_grid.valign = Gtk.Align.CENTER;
380 description_grid.column_spacing = 12;411 description_grid.vexpand = true;
381 description_grid.row_spacing = 6;412 description_grid.column_spacing = 24;
382 description_grid.orientation = Gtk.Orientation.VERTICAL;413 description_grid.add (software_grid);
383 description_grid.attach (logo, 0, 0, 1, 3);414 description_grid.add (new Gtk.Separator (Gtk.Orientation.VERTICAL));
384 description_grid.attach (title_grid, 1, 0, 1, 1);415 description_grid.add (hardware_grid);
385 if (upstream_release != null) {416
386 description_grid.attach (based_off, 1, 1, 1, 1);417 if (oem_enabled) {
418 var fileicon = new FileIcon (File.new_for_path (manufacturer_icon_path));
419
420 if (manufacturer_icon_path != null) {
421 manufacturer_logo.icon_name = null;
422 manufacturer_logo.gicon = fileicon;
423 }
424
425 var manufacturer_info = new Gtk.Label (manufacturer_name);
426 manufacturer_info.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
427 manufacturer_info.set_selectable (true);
428
429 hardware_grid.attach (manufacturer_info, 0, 2, 2, 1);
430
431 if (product_name != null) {
432 var product_name_info = new Gtk.Label (product_name);
433 product_name_info.get_style_context ().add_class ("h2");
434 product_name_info.set_selectable (true);
435 product_name_info.xalign = 1;
436 hardware_grid.attach (product_name_info, 0, 1, 1, 1);
437 }
438
439 if (product_version != null) {
440 var product_version_info = new Gtk.Label ("(" + product_version + ")");
441 product_version_info.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
442 product_version_info.set_selectable (true);
443 product_version_info.xalign = 0;
444 hardware_grid.attach (product_version_info, 1, 1, 1, 1);
445 }
446
447 if (manufacturer_support_url != null) {
448 var manufacturer_website_info = new Gtk.LinkButton.with_label (manufacturer_support_url, _("Manufacturer Website"));
449 hardware_grid.attach (manufacturer_website_info, 0, 7, 2, 1);
450 }
387 }451 }
388452
389 description_grid.attach (website_label, 1, 2, 1, 1);
390 description_grid.attach (hardware_title, 0, 3, 2, 1);
391 description_grid.attach (processor_label, 0, 4, 1, 1);
392 description_grid.attach (processor_info, 1, 4, 1, 1);
393 description_grid.attach (memory_label, 0, 5, 1, 1);
394 description_grid.attach (memory_info, 1, 5, 1, 1);
395 description_grid.attach (graphics_label, 0, 6, 1, 1);
396 description_grid.attach (graphics_info, 1, 6, 1, 1);
397 description_grid.attach (hdd_label, 0, 7, 1, 1);
398 description_grid.attach (hdd_info, 1, 7, 1, 1);
399
400 main_grid = new Gtk.Grid ();453 main_grid = new Gtk.Grid ();
401 main_grid.orientation = Gtk.Orientation.VERTICAL;454 main_grid.orientation = Gtk.Orientation.VERTICAL;
402 main_grid.halign = Gtk.Align.CENTER;455 main_grid.halign = Gtk.Align.CENTER;

Subscribers

People subscribed via source and target branches