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
1=== modified file 'src/Plug.vala'
2--- src/Plug.vala 2017-04-09 21:01:56 +0000
3+++ src/Plug.vala 2017-04-14 19:25:56 +0000
4@@ -26,6 +26,12 @@
5 private string memory;
6 private string graphics;
7 private string hdd;
8+ private bool oem_enabled;
9+ private string manufacturer_name;
10+ private string manufacturer_icon_path;
11+ private string manufacturer_support_url;
12+ private string product_name;
13+ private string product_version;
14 private Gtk.Label based_off;
15
16
17@@ -214,6 +220,35 @@
18 critical (e.message);
19 hdd = _("Unknown");
20 }
21+
22+ try {
23+ var oem_file = new KeyFile ();
24+ oem_file.load_from_file ("/etc/oem.conf", KeyFileFlags.NONE);
25+ // Assume we get the manufacturer name
26+ manufacturer_name = oem_file.get_string ("OEM", "MANUFACTURER");
27+
28+ // We need to check if the key is here because get_string throws an error if the key isn't available.
29+ if (oem_file.has_key ("OEM", "PRODUCT")) {
30+ product_name = oem_file.get_string ("OEM", "PRODUCT");
31+ }
32+
33+ if (oem_file.has_key ("OEM", "VERSION")) {
34+ product_version = oem_file.get_string ("OEM", "VERSION");
35+ }
36+
37+ if (oem_file.has_key ("OEM", "LOGO")) {
38+ manufacturer_icon_path = oem_file.get_string ("OEM", "LOGO");
39+ }
40+
41+ if (oem_file.has_key ("OEM", "URL")) {
42+ manufacturer_support_url = oem_file.get_string ("OEM", "URL");
43+ }
44+
45+ oem_enabled = true;
46+ } catch (Error e) {
47+ debug (e.message);
48+ oem_enabled = false;
49+ }
50 }
51
52 private string get_graphics_from_string(string graphics) {
53@@ -241,70 +276,37 @@
54 private void setup_ui () {
55 // Create the section about elementary OS
56 var logo = new Gtk.Image.from_icon_name ("distributor-logo", Gtk.icon_size_register ("LOGO", 128, 128));
57- logo.halign = Gtk.Align.END;
58+ logo.hexpand = true;
59
60 var title = new Gtk.Label (os);
61 title.get_style_context ().add_class ("h2");
62+ title.xalign = 1;
63 title.set_selectable (true);
64
65 var arch_name = new Gtk.Label ("(%s)".printf (arch));
66 arch_name.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
67- arch_name.valign = Gtk.Align.CENTER;
68-
69- var title_grid = new Gtk.Grid ();
70- title_grid.column_spacing = 6;
71- title_grid.valign = Gtk.Align.END;
72- title_grid.halign = Gtk.Align.START;
73- title_grid.vexpand = true;
74- title_grid.add (title);
75- title_grid.add (arch_name);
76+ arch_name.xalign = 0;
77
78 if (upstream_release != null) {
79 based_off = new Gtk.Label (_("Built on %s").printf (upstream_release));
80 based_off.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
81- based_off.halign = Gtk.Align.START;
82 based_off.set_selectable (true);
83 }
84
85 var website_label = new Gtk.LinkButton.with_label (website_url, _("Website"));
86- website_label.halign = Gtk.Align.START;
87- website_label.valign = Gtk.Align.START;
88- website_label.vexpand = true;
89-
90- var hardware_title = new Gtk.Label (null);
91- hardware_title.set_label (_("Hardware"));
92- hardware_title.get_style_context ().add_class ("h4");
93- hardware_title.halign = Gtk.Align.START;
94- hardware_title.margin_top = 24;
95-
96- var processor_label = new Gtk.Label (_("Processor:"));
97- processor_label.xalign = 1;
98-
99- var memory_label = new Gtk.Label (_("Memory:"));
100- memory_label.xalign = 1;
101-
102- var graphics_label = new Gtk.Label (_("Graphics:"));
103- graphics_label.xalign = 1;
104-
105- var hdd_label = new Gtk.Label (_("Storage:"));
106- hdd_label.xalign = 1;
107-
108- var processor_info = new Gtk.Label (processor);
109- processor_info.xalign = 0;
110+ website_label.margin_top = 12;
111+
112+ var processor_info = new Gtk.Label (_("%s processor").printf (processor));
113+ processor_info.margin_top = 12;
114 processor_info.set_selectable (true);
115- processor_info.set_line_wrap (false);
116
117- var memory_info = new Gtk.Label (memory);
118- memory_info.xalign = 0;
119+ var memory_info = new Gtk.Label (_("%s memory").printf (memory));
120 memory_info.set_selectable (true);
121
122- var graphics_info = new Gtk.Label (graphics);
123- graphics_info.xalign = 0;
124+ var graphics_info = new Gtk.Label (_("%s graphics").printf (graphics));
125 graphics_info.set_selectable (true);
126- graphics_info.set_line_wrap (false);
127
128- var hdd_info = new Gtk.Label (hdd);
129- hdd_info.xalign = 0;
130+ var hdd_info = new Gtk.Label (_("%s storage").printf (hdd));
131 hdd_info.set_selectable (true);
132
133 var help_button = new Gtk.Button.with_label ("?");
134@@ -367,36 +369,87 @@
135 button_grid.add (bug_button);
136 button_grid.add (update_button);
137
138- var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
139- size_group.add_widget (settings_restore_button);
140- size_group.add_widget (translate_button);
141- size_group.add_widget (bug_button);
142- size_group.add_widget (update_button);
143-
144- // Fit everything in a grid
145+ var button_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
146+ button_size_group.add_widget (settings_restore_button);
147+ button_size_group.add_widget (translate_button);
148+ button_size_group.add_widget (bug_button);
149+ button_size_group.add_widget (update_button);
150+
151+ var software_grid = new Gtk.Grid ();
152+ software_grid.column_spacing = 6;
153+ software_grid.row_spacing = 6;
154+ software_grid.attach (logo, 0, 0, 2, 1);
155+ software_grid.attach (title, 0, 1, 1, 1);
156+ software_grid.attach (arch_name, 1, 1, 1, 1);
157+
158+ if (upstream_release != null) {
159+ software_grid.attach (based_off, 0, 2, 2, 1);
160+ }
161+
162+ software_grid.attach (website_label, 0, 3, 2, 1);
163+
164+ var manufacturer_logo = new Gtk.Image ();
165+ manufacturer_logo.pixel_size = 128;
166+ manufacturer_logo.icon_name = "computer";
167+
168+ var hardware_grid = new Gtk.Grid ();
169+ hardware_grid.column_spacing = 6;
170+ hardware_grid.row_spacing = 6;
171+ hardware_grid.attach (manufacturer_logo, 0, 0, 2, 1);
172+ hardware_grid.attach (processor_info, 0, 3, 2, 1);
173+ hardware_grid.attach (graphics_info, 0, 4, 2, 1);
174+ hardware_grid.attach (memory_info, 0, 5, 2, 1);
175+ hardware_grid.attach (hdd_info, 0, 6, 2, 1);
176+
177+ var description_size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
178+ description_size_group.add_widget (hardware_grid);
179+ description_size_group.add_widget (software_grid);
180+
181 var description_grid = new Gtk.Grid ();
182 description_grid.halign = Gtk.Align.CENTER;
183 description_grid.valign = Gtk.Align.CENTER;
184- description_grid.column_spacing = 12;
185- description_grid.row_spacing = 6;
186- description_grid.orientation = Gtk.Orientation.VERTICAL;
187- description_grid.attach (logo, 0, 0, 1, 3);
188- description_grid.attach (title_grid, 1, 0, 1, 1);
189- if (upstream_release != null) {
190- description_grid.attach (based_off, 1, 1, 1, 1);
191+ description_grid.vexpand = true;
192+ description_grid.column_spacing = 24;
193+ description_grid.add (software_grid);
194+ description_grid.add (new Gtk.Separator (Gtk.Orientation.VERTICAL));
195+ description_grid.add (hardware_grid);
196+
197+ if (oem_enabled) {
198+ var fileicon = new FileIcon (File.new_for_path (manufacturer_icon_path));
199+
200+ if (manufacturer_icon_path != null) {
201+ manufacturer_logo.icon_name = null;
202+ manufacturer_logo.gicon = fileicon;
203+ }
204+
205+ var manufacturer_info = new Gtk.Label (manufacturer_name);
206+ manufacturer_info.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
207+ manufacturer_info.set_selectable (true);
208+
209+ hardware_grid.attach (manufacturer_info, 0, 2, 2, 1);
210+
211+ if (product_name != null) {
212+ var product_name_info = new Gtk.Label (product_name);
213+ product_name_info.get_style_context ().add_class ("h2");
214+ product_name_info.set_selectable (true);
215+ product_name_info.xalign = 1;
216+ hardware_grid.attach (product_name_info, 0, 1, 1, 1);
217+ }
218+
219+ if (product_version != null) {
220+ var product_version_info = new Gtk.Label ("(" + product_version + ")");
221+ product_version_info.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL);
222+ product_version_info.set_selectable (true);
223+ product_version_info.xalign = 0;
224+ hardware_grid.attach (product_version_info, 1, 1, 1, 1);
225+ }
226+
227+ if (manufacturer_support_url != null) {
228+ var manufacturer_website_info = new Gtk.LinkButton.with_label (manufacturer_support_url, _("Manufacturer Website"));
229+ hardware_grid.attach (manufacturer_website_info, 0, 7, 2, 1);
230+ }
231 }
232
233- description_grid.attach (website_label, 1, 2, 1, 1);
234- description_grid.attach (hardware_title, 0, 3, 2, 1);
235- description_grid.attach (processor_label, 0, 4, 1, 1);
236- description_grid.attach (processor_info, 1, 4, 1, 1);
237- description_grid.attach (memory_label, 0, 5, 1, 1);
238- description_grid.attach (memory_info, 1, 5, 1, 1);
239- description_grid.attach (graphics_label, 0, 6, 1, 1);
240- description_grid.attach (graphics_info, 1, 6, 1, 1);
241- description_grid.attach (hdd_label, 0, 7, 1, 1);
242- description_grid.attach (hdd_info, 1, 7, 1, 1);
243-
244 main_grid = new Gtk.Grid ();
245 main_grid.orientation = Gtk.Orientation.VERTICAL;
246 main_grid.halign = Gtk.Align.CENTER;

Subscribers

People subscribed via source and target branches