Skip to content

Commit de589e8

Browse files
committed
Remove the app item from the items list - fix removing non existent items from the sidebar; create new application entry with the same category of the selected app
1 parent fd958f7 commit de589e8

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/AppInfoView.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,7 @@ public class AppEditor.AppInfoView : Gtk.Box {
283283
error_label.label = _("Something went wrong and the changes could not be saved: %s".printf (e.message));
284284
}
285285

286-
validate_cmdline_entry ();
287-
update_restore_button ();
286+
update_page ();
288287
}
289288

290289
public bool get_changed () {
@@ -435,6 +434,7 @@ public class AppEditor.AppInfoView : Gtk.Box {
435434
terminal_switch.active = desktop_app.get_terminal ();
436435
notifications_switch.active = desktop_app.info.get_boolean (DesktopApp.USES_NOTIFICATIONS_KEY);
437436

437+
validate_cmdline_entry ();
438438
update_restore_button ();
439439
}
440440

src/AppInfoViewSaver.vala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@
2020
public class AppEditor.AppInfoViewSaver : Object {
2121
public AppInfoView target { get; set; }
2222

23-
public static DesktopApp? create_new_local_app () {
23+
public static DesktopApp? create_new_local_app (AppCategory? category) {
2424
string lang = Intl.get_language_names ()[0];
2525

2626
var key = new KeyFile ();
2727
key.set_list_separator (DesktopApp.DEFAULT_LIST_SEPARATOR);
2828
key.set_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_TYPE, KeyFileDesktop.TYPE_APPLICATION);
2929
key.set_locale_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_NAME, lang, _("New Application"));
30+
if (category != null) {
31+
string[] categories = { category.id };
32+
key.set_string_list (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_CATEGORIES, categories);
33+
}
3034

3135
string path = AppDirectoryScanner.get_config_path ();
3236

src/AppSourceList.vala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public class AppEditor.AppSourceList : Granite.Widgets.SourceList {
9292
foreach (var app_item in app_items) {
9393
if (app_item.desktop_app.compare (desktop_app)) {
9494
app_item.parent.remove (app_item);
95+
app_items.remove (app_item);
9596
break;
9697
}
9798
}

src/MainWindow.vala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,13 @@ public class AppEditor.MainWindow : Gtk.Window {
265265
private void on_new_button_clicked () {
266266
search_entry.text = "";
267267

268-
var new_app = AppInfoViewSaver.create_new_local_app ();
268+
AppCategory? current_category = null;
269+
var current_view = app_info_view_stack.get_current_view ();
270+
if (current_view != null) {
271+
current_category = current_view.desktop_app.get_main_category ();
272+
}
273+
274+
var new_app = AppInfoViewSaver.create_new_local_app (current_category);
269275
app_source_list.add_app (new_app, true);
270276
}
271277

0 commit comments

Comments
 (0)