Allow native commands as external editors

If an editor is marked as a native command, it is launched using the
older method (native for Windows or Glib otherwise). Non-native commands
are launched with Gio. When reading preferences containing the old style
external editor settings, all commands are marked as native to avoid
breaking them.

Fix bug where the send to editor button shows the wrong editor. The bug
happens when the other editor option is selected while the user edits
the external editors in preferences. When saved, the button shows the
first option is selected instead of the other editor option (the last
entry).
This commit is contained in:
Lawrence Lee
2023-04-08 18:16:23 -07:00
parent dc1c667790
commit 19f12f3182
10 changed files with 97 additions and 32 deletions

View File

@@ -50,6 +50,7 @@ public:
Glib::ustring name = Glib::ustring(),
Glib::ustring command = Glib::ustring(),
Glib::ustring icon_serialized = Glib::ustring(),
bool native_command = false,
void *other_data = nullptr
);
/**
@@ -65,6 +66,10 @@ public:
* Gio::AppInfo::get_commandline()
*/
Glib::ustring command;
/**
* Use the OS native launcher instead of Gio.
*/
bool native_command;
/**
* Holds any other data associated with the editor. For example, it can
* be used as a tag to uniquely identify the editor.
@@ -96,6 +101,7 @@ private:
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn<Glib::RefPtr<Gio::Icon>> icon;
Gtk::TreeModelColumn<Glib::ustring> command;
Gtk::TreeModelColumn<bool> native_command;
Gtk::TreeModelColumn<void *> other_data;
};
@@ -124,6 +130,10 @@ private:
* Constructs the column for displaying an editable commandline.
*/
Gtk::TreeViewColumn *makeCommandColumn();
/**
* Constructs the column for displaying the native command toggle.
*/
Gtk::TreeViewColumn *makeNativeCommandColumn();
/**
* Called when the user is done interacting with the app chooser dialog.
* Closes the dialog and updates the selected entry if an app was chosen.