Got rid of shortcut icons

This commit is contained in:
2025-09-30 19:04:52 +02:00
parent a99b9fe0bb
commit 561f76581b
6 changed files with 11 additions and 56 deletions

View File

@@ -10,8 +10,6 @@ public class AddShortcutWindow
private const string dialogId = "add_shortcut_dialog"; private const string dialogId = "add_shortcut_dialog";
private Gtk.Button? closeButton; private Gtk.Button? closeButton;
private const string closeButtonId = "close_button"; private const string closeButtonId = "close_button";
private Gtk.Button? iconPickerButton;
private const string iconPickerButtonId = "icon_picker_button";
private EntryRow? displayNameEntryRow; private EntryRow? displayNameEntryRow;
private const string displayNameEntryRowId = "display_name_entry_row"; private const string displayNameEntryRowId = "display_name_entry_row";
private ActionRow? folderActionRow; private ActionRow? folderActionRow;
@@ -44,13 +42,6 @@ public class AddShortcutWindow
} }
closeButton.OnClicked += Close; closeButton.OnClicked += Close;
iconPickerButton = builder.GetObject(iconPickerButtonId) as Gtk.Button;
if (iconPickerButton == null)
{
throw new NullReferenceException(iconPickerButtonId);
}
iconPickerButton.OnClicked += OpenIconPicker;
displayNameEntryRow = builder.GetObject(displayNameEntryRowId) as EntryRow; displayNameEntryRow = builder.GetObject(displayNameEntryRowId) as EntryRow;
if (displayNameEntryRow == null) if (displayNameEntryRow == null)
{ {
@@ -92,31 +83,19 @@ public class AddShortcutWindow
private void CreateShortcut() private void CreateShortcut()
{ {
if (displayNameEntryRow == null || browseButton == null || iconPickerButton == null) if (displayNameEntryRow == null || browseButton == null)
return; return;
var displayName = displayNameEntryRow.GetText(); var displayName = displayNameEntryRow.GetText();
var path = ((ButtonContent)browseButton.Child).Label; var path = ((ButtonContent)browseButton.Child).Label;
var iconName = iconPickerButton.Label;
if (string.IsNullOrWhiteSpace(displayName) || path.Equals("Browse") || string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(iconName)) if (string.IsNullOrWhiteSpace(displayName) || path.Equals("Browse") || string.IsNullOrWhiteSpace(path))
return; return;
shortcuts.Add(path, displayName, iconName); shortcuts.Add(path, displayName);
Dialog.Close(); Dialog.Close();
} }
private void OpenIconPicker(object sender, EventArgs e)
{
var chooser = new Gtk.EmojiChooser();
chooser.SetParent(iconPickerButton);
chooser.OnEmojiPicked += (s, e) =>
{
iconPickerButton.Label = e.Text;
};
chooser.Show();
}
private void Close(object sender, EventArgs e) private void Close(object sender, EventArgs e)
{ {
Dialog.Close(); Dialog.Close();

View File

@@ -38,7 +38,7 @@
<property name="title" translatable="yes" context="Input field placeholder" comments="Noun. Tells the user that the display name of the new password store is to be supplied here">Name</property> <property name="title" translatable="yes" context="Input field placeholder" comments="Noun. Tells the user that the display name of the new password store is to be supplied here">Name</property>
</object> </object>
</child> </child>
<child> <!-- <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<property name="title">Icon</property> <property name="title">Icon</property>
<child> <child>
@@ -49,7 +49,7 @@
</object> </object>
</child> </child>
</object> </object>
</child> </child> -->
<child> <child>
<object class="AdwActionRow" id="folder_action_row"> <object class="AdwActionRow" id="folder_action_row">
<property name="title" translatable="yes" context="Label" comments="Noun. Marks a button that allows the user to pick a folder where the new store will be.">Location</property> <property name="title" translatable="yes" context="Label" comments="Noun. Marks a button that allows the user to pick a folder where the new store will be.">Location</property>

View File

@@ -136,16 +136,12 @@
</child> </child>
</object> </object>
</property> </property>
<child> <!-- Dynamic rows will be added here via model binding -->
<!-- <child>
<object class="AdwActionRow"> <object class="AdwActionRow">
<property name="title">Sample password</property> <property name="title">Sample password</property>
</object> </object>
</child> </child> -->
<child>
<object class="AdwActionRow">
<property name="title">Sample password 2</property>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>

View File

@@ -77,19 +77,6 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
row.SetTitle(shortcut.DisplayName); row.SetTitle(shortcut.DisplayName);
row.SetSubtitle(shortcut.Path); row.SetSubtitle(shortcut.Path);
//Update icon
var existingIcon = row.GetFirstChild() as Gtk.Image;
if (existingIcon == null)
{
var icon = new Gtk.Image();
icon.SetFromIconName(shortcut.IconName);
row.AddPrefix(icon);
}
else
{
existingIcon.SetFromIconName(shortcut.IconName);
}
// Edit button // Edit button
var edit = new Button(); var edit = new Button();
edit.AddCssClass("flat"); edit.AddCssClass("flat");
@@ -98,9 +85,9 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
row.AddSuffix(edit); row.AddSuffix(edit);
} }
public void Add(string path, string? displayName = null, string? iconName = null) public void Add(string path, string? displayName = null)
{ {
PasswordStoreViewModel item = new PasswordStoreViewModel(path, displayName, iconName); PasswordStoreViewModel item = new PasswordStoreViewModel(path, displayName);
Add(item); Add(item);
_passwordStoreService.Create(item.Model); _passwordStoreService.Create(item.Model);
} }

View File

@@ -13,11 +13,6 @@ public class PasswordStoreViewModel : INotifyPropertyChanged
get => _model.DisplayName; get => _model.DisplayName;
} }
public string? IconName
{
get => _model.IconName;
}
public string Path public string Path
{ {
get => _model.Path; get => _model.Path;
@@ -30,13 +25,12 @@ public class PasswordStoreViewModel : INotifyPropertyChanged
_model = item; _model = item;
} }
public PasswordStoreViewModel(string path, string? displayName = "New Shortcut", string? iconName = "text-x-generic-symbolic") public PasswordStoreViewModel(string path, string? displayName = "New Shortcut")
{ {
_model = new PasswordStore _model = new PasswordStore
{ {
DisplayName = displayName, DisplayName = displayName,
Path = path, Path = path,
IconName = iconName
}; };
} }
} }

View File

@@ -5,5 +5,4 @@ public class PasswordStore
public uint ID { get; set; } public uint ID { get; set; }
public string Path { get; set; } public string Path { get; set; }
public string? DisplayName { get; set; } public string? DisplayName { get; set; }
public string? IconName { get; set; }
} }