Got rid of shortcut icons
This commit is contained in:
@@ -10,8 +10,6 @@ public class AddShortcutWindow
|
||||
private const string dialogId = "add_shortcut_dialog";
|
||||
private Gtk.Button? closeButton;
|
||||
private const string closeButtonId = "close_button";
|
||||
private Gtk.Button? iconPickerButton;
|
||||
private const string iconPickerButtonId = "icon_picker_button";
|
||||
private EntryRow? displayNameEntryRow;
|
||||
private const string displayNameEntryRowId = "display_name_entry_row";
|
||||
private ActionRow? folderActionRow;
|
||||
@@ -44,13 +42,6 @@ public class AddShortcutWindow
|
||||
}
|
||||
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;
|
||||
if (displayNameEntryRow == null)
|
||||
{
|
||||
@@ -92,31 +83,19 @@ public class AddShortcutWindow
|
||||
|
||||
private void CreateShortcut()
|
||||
{
|
||||
if (displayNameEntryRow == null || browseButton == null || iconPickerButton == null)
|
||||
if (displayNameEntryRow == null || browseButton == null)
|
||||
return;
|
||||
|
||||
var displayName = displayNameEntryRow.GetText();
|
||||
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;
|
||||
|
||||
shortcuts.Add(path, displayName, iconName);
|
||||
shortcuts.Add(path, displayName);
|
||||
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)
|
||||
{
|
||||
Dialog.Close();
|
||||
|
||||
@@ -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>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<!-- <child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title">Icon</property>
|
||||
<child>
|
||||
@@ -49,7 +49,7 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</child> -->
|
||||
<child>
|
||||
<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>
|
||||
|
||||
@@ -136,16 +136,12 @@
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
<child>
|
||||
<!-- Dynamic rows will be added here via model binding -->
|
||||
<!-- <child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title">Sample password</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="AdwActionRow">
|
||||
<property name="title">Sample password 2</property>
|
||||
</object>
|
||||
</child>
|
||||
</child> -->
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@@ -77,19 +77,6 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
|
||||
row.SetTitle(shortcut.DisplayName);
|
||||
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
|
||||
var edit = new Button();
|
||||
edit.AddCssClass("flat");
|
||||
@@ -98,9 +85,9 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
|
||||
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);
|
||||
_passwordStoreService.Create(item.Model);
|
||||
}
|
||||
|
||||
@@ -13,11 +13,6 @@ public class PasswordStoreViewModel : INotifyPropertyChanged
|
||||
get => _model.DisplayName;
|
||||
}
|
||||
|
||||
public string? IconName
|
||||
{
|
||||
get => _model.IconName;
|
||||
}
|
||||
|
||||
public string Path
|
||||
{
|
||||
get => _model.Path;
|
||||
@@ -30,13 +25,12 @@ public class PasswordStoreViewModel : INotifyPropertyChanged
|
||||
_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
|
||||
{
|
||||
DisplayName = displayName,
|
||||
Path = path,
|
||||
IconName = iconName
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,4 @@ public class PasswordStore
|
||||
public uint ID { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string? DisplayName { get; set; }
|
||||
public string? IconName { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user