Line |
Branch |
Exec |
Source |
1 |
|
|
/* cc-applications-row.c |
2 |
|
|
* |
3 |
|
|
* Copyright 2018 Matthias Clasen <matthias.clasen@gmail.com> |
4 |
|
|
* |
5 |
|
|
* This program is free software: you can redistribute it and/or modify |
6 |
|
|
* it under the terms of the GNU General Public License as published by |
7 |
|
|
* the Free Software Foundation, either version 3 of the License, or |
8 |
|
|
* (at your option) any later version. |
9 |
|
|
* |
10 |
|
|
* This program is distributed in the hope that it will be useful, |
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
|
|
* GNU General Public License for more details. |
14 |
|
|
* |
15 |
|
|
* You should have received a copy of the GNU General Public License |
16 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 |
|
|
* |
18 |
|
|
* SPDX-License-Identifier: GPL-3.0-or-later |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include <config.h> |
22 |
|
|
#include <glib/gi18n.h> |
23 |
|
|
|
24 |
|
|
#include "cc-applications-row.h" |
25 |
|
|
#include "cc-applications-resources.h" |
26 |
|
|
|
27 |
|
|
struct _CcApplicationsRow |
28 |
|
|
{ |
29 |
|
|
AdwActionRow parent; |
30 |
|
|
|
31 |
|
|
GAppInfo *info; |
32 |
|
|
}; |
33 |
|
|
|
34 |
|
✗ |
G_DEFINE_TYPE (CcApplicationsRow, cc_applications_row, ADW_TYPE_ACTION_ROW) |
35 |
|
|
|
36 |
|
|
static void |
37 |
|
✗ |
cc_applications_row_finalize (GObject *object) |
38 |
|
|
{ |
39 |
|
✗ |
CcApplicationsRow *self = CC_APPLICATIONS_ROW (object); |
40 |
|
|
|
41 |
|
✗ |
g_object_unref (self->info); |
42 |
|
|
|
43 |
|
✗ |
G_OBJECT_CLASS (cc_applications_row_parent_class)->finalize (object); |
44 |
|
✗ |
} |
45 |
|
|
|
46 |
|
|
static void |
47 |
|
✗ |
cc_applications_row_class_init (CcApplicationsRowClass *klass) |
48 |
|
|
{ |
49 |
|
✗ |
GObjectClass *object_class = G_OBJECT_CLASS (klass); |
50 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
51 |
|
|
|
52 |
|
✗ |
object_class->finalize = cc_applications_row_finalize; |
53 |
|
|
|
54 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/applications/cc-applications-row.ui"); |
55 |
|
✗ |
} |
56 |
|
|
|
57 |
|
|
static void |
58 |
|
✗ |
cc_applications_row_init (CcApplicationsRow *self) |
59 |
|
|
{ |
60 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
61 |
|
✗ |
} |
62 |
|
|
|
63 |
|
|
CcApplicationsRow * |
64 |
|
✗ |
cc_applications_row_new (GAppInfo *info) |
65 |
|
|
{ |
66 |
|
|
CcApplicationsRow *self; |
67 |
|
✗ |
g_autoptr(GIcon) icon = NULL; |
68 |
|
|
GtkWidget *w; |
69 |
|
|
|
70 |
|
✗ |
self = g_object_new (CC_TYPE_APPLICATIONS_ROW, NULL); |
71 |
|
|
|
72 |
|
✗ |
self->info = g_object_ref (info); |
73 |
|
|
|
74 |
|
✗ |
gtk_list_box_row_set_activatable (GTK_LIST_BOX_ROW (self), TRUE); |
75 |
|
✗ |
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (self), |
76 |
|
✗ |
g_markup_escape_text (g_app_info_get_display_name (info), -1)); |
77 |
|
|
|
78 |
|
✗ |
icon = g_app_info_get_icon (info); |
79 |
|
✗ |
if (icon != NULL) |
80 |
|
✗ |
g_object_ref (icon); |
81 |
|
|
else |
82 |
|
✗ |
icon = g_themed_icon_new ("application-x-executable"); |
83 |
|
✗ |
w = gtk_image_new_from_gicon (icon); |
84 |
|
✗ |
gtk_style_context_add_class (gtk_widget_get_style_context (w), "lowres-icon"); |
85 |
|
✗ |
gtk_image_set_icon_size (GTK_IMAGE (w), GTK_ICON_SIZE_LARGE); |
86 |
|
✗ |
adw_action_row_add_prefix (ADW_ACTION_ROW (self), w); |
87 |
|
|
|
88 |
|
✗ |
return self; |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
GAppInfo * |
92 |
|
✗ |
cc_applications_row_get_info (CcApplicationsRow *self) |
93 |
|
|
{ |
94 |
|
✗ |
return self->info; |
95 |
|
|
} |
96 |
|
|
|