2
* Copyright (c) 2014-2017 elementary LLC. (http://launchpad.net/switchboard-plug-security-privacy)
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 3 of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301 USA
19
* Authored by: Julien Spautz <spautz.julien@gmail.com>
20
* Corentin Noël <corentin@elementaryos.org>
23
public class AppRow : Gtk.Grid {
24
public DesktopAppInfo app_info { get; construct; }
26
public AppRow (DesktopAppInfo app_info) {
27
Object (app_info: app_info);
31
var image = new Gtk.Image.from_icon_name (get_icon_name (), Gtk.IconSize.DND);
32
image.pixel_size = 32;
34
var app_name = new Gtk.Label (get_app_name ());
35
app_name.get_style_context ().add_class ("h3");
38
var app_comment = new Gtk.Label ("<span font_size='small'>" + get_app_comment () + "</span>");
39
app_comment.xalign = 0;
40
app_comment.use_markup = true;
44
margin_start = 10; // Account for icon position on the canvas
46
attach (image, 0, 0, 1, 2);
47
attach (app_name, 1, 0, 1, 1);
48
attach (app_comment, 1, 1, 1, 1);
53
private string get_app_comment () {
54
var comment = app_info.get_description ();
56
if (comment == null) {
60
return Markup.escape_text (comment);
63
private string get_app_name () {
64
var name = app_info.get_display_name ();
67
name = app_info.get_name ();
70
return Markup.escape_text (name);
73
private string get_icon_name () {
74
var icon_theme = Gtk.IconTheme.get_default ();
76
if (icon_theme.has_icon (app_info.get_icon ().to_string ())) {
77
return app_info.get_icon ().to_string ();
79
return "application-default-icon";