Skip to content

Commit 58d5772

Browse files
committed
PackageKit improvements (#50)
1 parent d447b0e commit 58d5772

7 files changed

+57
-27
lines changed

Diff for: lib/package_installer/package_installer_model.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ class PackageInstallerModel extends SafeChangeNotifier {
1212
_size = 0,
1313
_summary = '',
1414
_url = '',
15-
_installedPackageIds = {};
15+
_installedPackageIds = {} {
16+
_client.connect();
17+
}
1618

1719
final PackageKitClient _client;
1820
final String path;

Diff for: lib/store_app/my_apps/my_packages_model.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import 'package:safe_change_notifier/safe_change_notifier.dart';
66
class MyPackagesModel extends SafeChangeNotifier {
77
final PackageKitClient _client;
88

9-
MyPackagesModel(this._client) : _packageIds = {};
9+
MyPackagesModel(this._client) : _packageIds = {} {
10+
_client.connect();
11+
}
1012

1113
final Set<PackageKitPackageId> _packageIds;
1214
List<PackageKitPackageId> get packages => _packageIds.toList();

Diff for: lib/store_app/my_apps/package_dialog.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class _PackageDialogState extends State<PackageDialog> {
7171
onPressed: model.processing ? null : model.remove,
7272
child: Text(context.l10n.remove),
7373
),
74-
if (!model.updateAvailable)
74+
if (!model.updateAvailable && !model.packageIsInstalled)
7575
ElevatedButton(
7676
onPressed: model.processing ? null : model.install,
7777
child: Text(context.l10n.install),

Diff for: lib/store_app/my_apps/package_model.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ class PackageModel extends SafeChangeNotifier {
1111
_size = 0,
1212
_summary = '',
1313
_url = '',
14-
_installedPackageIds = [];
14+
_installedPackageIds = [] {
15+
_client.connect();
16+
}
1517

1618
final PackageKitClient _client;
1719

Diff for: lib/store_app/my_apps/system_updates_model.dart

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:async';
2+
import 'dart:io';
23

34
import 'package:packagekit/packagekit.dart';
45
import 'package:safe_change_notifier/safe_change_notifier.dart';
@@ -9,10 +10,19 @@ class SystemUpdatesModel extends SafeChangeNotifier {
910
final List<PackageKitPackageId> updates = [];
1011
String errorString = '';
1112
bool updating = false;
13+
String _manualRepoName = '';
14+
set manualRepoName(String value) {
15+
if (value == _manualRepoName) return;
16+
_manualRepoName = value;
17+
notifyListeners();
18+
}
1219

13-
SystemUpdatesModel(this._client);
20+
SystemUpdatesModel(this._client) {
21+
_client.connect();
22+
}
1423

1524
Future<void> getUpdates() async {
25+
updates.clear();
1626
errorString = '';
1727
final transaction = await _client.createTransaction();
1828
final completer = Completer();
@@ -92,7 +102,19 @@ class SystemUpdatesModel extends SafeChangeNotifier {
92102
}
93103

94104
// Not implemented in packagekit.dart
95-
Future<void> addRepo(String id) async {}
96-
// Not implemented in packagekit.dart
105+
Future<void> addRepo() async {
106+
if (_manualRepoName.isEmpty) return;
107+
Process.start(
108+
'pkexec',
109+
[
110+
'apt-add-repository',
111+
_manualRepoName,
112+
],
113+
mode: ProcessStartMode.detached,
114+
);
115+
loadRepoList();
116+
}
117+
118+
// Not implemented in packagekit.dart and too hard for apt-add-repository
97119
Future<void> removeRepo(String id) async {}
98120
}

Diff for: lib/store_app/my_apps/system_updates_page.dart

+21-19
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ class _SystemUpdatesPageState extends State<SystemUpdatesPage> {
7171
const SizedBox(
7272
width: 10,
7373
),
74+
SizedBox(
75+
width: 40,
76+
child: YaruRoundIconButton(
77+
onTap: () => model.getUpdates(),
78+
child: const Icon(YaruIcons.refresh),
79+
),
80+
),
81+
const SizedBox(
82+
width: 10,
83+
),
7484
if (model.updates.isNotEmpty)
7585
ElevatedButton(
7686
onPressed: model.updating ? null : () => model.updateAll(),
@@ -89,16 +99,6 @@ class _SystemUpdatesPageState extends State<SystemUpdatesPage> {
8999
context.l10n.noUpdates,
90100
style: Theme.of(context).textTheme.headline4,
91101
),
92-
const SizedBox(
93-
width: 10,
94-
),
95-
SizedBox(
96-
width: 40,
97-
child: YaruRoundIconButton(
98-
onTap: () => model.getUpdates(),
99-
child: const Icon(YaruIcons.refresh),
100-
),
101-
),
102102
],
103103
),
104104
)
@@ -110,6 +110,7 @@ class _SystemUpdatesPageState extends State<SystemUpdatesPage> {
110110
itemBuilder: (context, index) {
111111
return AppBanner(
112112
name: model.updates[index].name,
113+
summary: model.updates[index].version,
113114
icon: const Icon(
114115
YaruIcons.package_deb,
115116
size: 50,
@@ -137,7 +138,14 @@ class _RepoDialog extends StatefulWidget {
137138
}
138139

139140
class _RepoDialogState extends State<_RepoDialog> {
140-
final controller = TextEditingController();
141+
late TextEditingController controller;
142+
143+
@override
144+
void initState() {
145+
controller = TextEditingController();
146+
super.initState();
147+
}
148+
141149
@override
142150
void dispose() {
143151
controller.dispose();
@@ -154,9 +162,7 @@ class _RepoDialogState extends State<_RepoDialog> {
154162
titleWidget: Row(
155163
children: [
156164
YaruRoundIconButton(
157-
onTap: controller.text.isNotEmpty
158-
? () => model.addRepo(controller.text)
159-
: null,
165+
onTap: controller.text.isEmpty ? null : () => model.addRepo(),
160166
child: const Icon(YaruIcons.plus),
161167
),
162168
const SizedBox(
@@ -165,6 +171,7 @@ class _RepoDialogState extends State<_RepoDialog> {
165171
SizedBox(
166172
width: 300,
167173
child: TextField(
174+
onChanged: (value) => model.manualRepoName = value,
168175
controller: controller,
169176
decoration: InputDecoration(
170177
hintText: context.l10n.enterRepoName,
@@ -182,13 +189,8 @@ class _RepoDialogState extends State<_RepoDialog> {
182189
value: e.enabled,
183190
onChanged: (v) => model.toggleRepo(id: e.repoId, value: v!),
184191
title: ListTile(
185-
leading: YaruRoundIconButton(
186-
child: const Icon(YaruIcons.trash),
187-
onTap: () => model.removeRepo(e.repoId),
188-
),
189192
title: Text(e.repoId),
190193
subtitle: Text(e.description),
191-
isThreeLine: true,
192194
),
193195
),
194196
)

Diff for: linux/my_application.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static void my_application_activate(GApplication* application) {
5454
gtk_window_set_geometry_hints(window, nullptr, &geometry_min, GDK_HINT_MIN_SIZE);
5555

5656

57-
gtk_window_set_default_size(window, 800, 730);
57+
gtk_window_set_default_size(window, 800, 870);
5858

5959
g_autoptr(FlDartProject) project = fl_dart_project_new();
6060
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);

0 commit comments

Comments
 (0)