Skip to content

Commit

Permalink
Some Plugins window fixes (WinMerge#2621)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka authored Jan 19, 2025
1 parent 67f3afb commit 2b2ad2a
Show file tree
Hide file tree
Showing 42 changed files with 191 additions and 143 deletions.
4 changes: 2 additions & 2 deletions Src/InternalPlugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ Info* GetInternalPluginInfo(const PluginInfo* plugin)

bool FindPluginNameConflict(const Info& info)
{
for (auto& eventNames : { plugin::UnpackerEventNames, plugin::PredifferEventNames, plugin::EditorScriptEventNames })
for (auto& eventNames : { plugin::ProtocolHanlderEventNames, plugin::UnpackerEventNames, plugin::PredifferEventNames, plugin::EditorScriptEventNames })
{
if (std::find(eventNames.begin(), eventNames.end(), info.m_event) != eventNames.end())
{
Expand Down Expand Up @@ -830,7 +830,7 @@ bool RemovePlugin(const Info& info, String& errmsg)
return false;
for (auto it = list.begin(); it != list.end(); ++it)
{
if (it->m_name == info.m_name)
if (it->m_name == info.m_name && it->m_event == info.m_event)
{
list.erase(it);
break;
Expand Down
29 changes: 24 additions & 5 deletions Src/Merge.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2346,16 +2346,18 @@ BEGIN
END

IDD_PLUGINS_LIST DIALOGEX 0, 0, 470, 257
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Plugins"
FONT 8, FONTNAME, 0, 0, 0x1
BEGIN
CONTROL "&Enable plugins",IDC_PLUGINS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,266,10
CONTROL "",IDC_PLUGINSLIST_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,22,456,155
CONTROL "&Enable plugins",IDC_PLUGINS_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,455,10
LTEXT "Plugin &type:",IDC_STATIC,7,21,70,10
COMBOBOX IDC_PLUGIN_TYPE,80,20,306,14,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "",IDC_PLUGINSLIST_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,38,456,139
LTEXT "File filters:",IDC_STATIC,7,183,70,10
COMBOBOX IDC_PLUGIN_FILEFILTERS,80,183,305,14,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LTEXT "&Plugin arguments:",IDC_STATIC,7,200,70,10
EDITTEXT IDC_PLUGIN_ARGUMENTS,80,200,305,14,ES_AUTOHSCROLL | WS_GROUP
EDITTEXT IDC_PLUGIN_ARGUMENTS,80,200,305,12,ES_AUTOHSCROLL | WS_GROUP
CONTROL "Enable &automatic unpacking/prediffing for the plugin",IDC_PLUGIN_AUTOMATIC,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,218,300,10
PUSHBUTTON "Defaults",IDC_PLUGIN_DEFAULTS,393,183,70,14
Expand Down Expand Up @@ -3363,7 +3365,24 @@ END

IDD_PLUGINS_LIST AFX_DIALOG_LAYOUT
BEGIN
0
0,
0, 0, 100, 0,
0, 0, 0, 0,
0, 0, 100, 0,
0, 0, 100, 100,
0, 100, 0, 0,
0, 100, 100, 0,
0, 100, 0, 0,
0, 100, 100, 0,
0, 100, 0, 0,
100, 100, 0, 0,
0, 100, 0, 0,
0, 100, 0, 0,
0, 100, 0, 0,
0, 100, 0, 0,
100, 100, 0, 0,
100, 100, 0, 0,
100, 100, 0, 0
END

IDD_PROPPAGE_COLORS_SYSTEM AFX_DIALOG_LAYOUT
Expand Down
63 changes: 44 additions & 19 deletions Src/PluginsListDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ BEGIN_MESSAGE_MAP(PluginsListDlg, CTrDialog)
ON_BN_CLICKED(IDC_PLUGIN_DEFAULTS, OnBnClickedFileFiltesDefaults)
ON_CBN_DROPDOWN(IDC_PLUGIN_FILEFILTERS, OnDropDownPatterns)
ON_CBN_CLOSEUP(IDC_PLUGIN_FILEFILTERS, OnCloseUpPatterns)
ON_CBN_SELCHANGE(IDC_PLUGIN_TYPE, OnSelchangePluginType)
ON_NOTIFY(NM_DBLCLK, IDC_PLUGINSLIST_LIST, OnNMDblclkList)
ON_NOTIFY(LVN_ITEMCHANGING, IDC_PLUGINSLIST_LIST, OnLVNItemChanging)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_PLUGINSLIST_LIST, OnLVNItemChanged)
Expand All @@ -58,6 +59,7 @@ PluginsListDlg::~PluginsListDlg()
void PluginsListDlg::DoDataExchange(CDataExchange* pDX)
{
CTrDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PLUGIN_TYPE, m_comboType);
DDX_Control(pDX, IDC_PLUGINSLIST_LIST, m_list);
DDX_Control(pDX, IDC_PLUGIN_FILEFILTERS, m_comboPatterns);
}
Expand All @@ -77,12 +79,19 @@ BOOL PluginsListDlg::OnInitDialog()


InitList();
AddPlugins();
SetDlgItemComboBoxList(IDC_PLUGIN_TYPE, { _("Unpacker"), _("Prediffer"), _("Editor script") });
m_comboType.SetCurSel(0);
SetPlugins(0);
m_list.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);

CheckDlgButton(IDC_PLUGINS_ENABLE,
GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED) ? BST_CHECKED : BST_UNCHECKED);

m_constraint.InitializeCurrentSize(this);
m_constraint.SubclassWnd(); // install subclassing
// persist size via registry
m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("PluginsListDlg"), false);

return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Expand All @@ -102,34 +111,40 @@ void PluginsListDlg::InitList()
String title = _("Name");
m_list.InsertColumn(0, title.c_str(), LVCFMT_LEFT, pointToPixel(150));
title = _("Type");
m_list.InsertColumn(1, title.c_str(), LVCFMT_LEFT, pointToPixel(150));
m_list.InsertColumn(1, title.c_str(), LVCFMT_LEFT, pointToPixel(100));
title = _("Description");
m_list.InsertColumn(2, title.c_str(), LVCFMT_LEFT, pointToPixel(300));
m_list.InsertColumn(2, title.c_str(), LVCFMT_LEFT, pointToPixel(600));
}

/**
* @brief Add found plugins to the list.
*/
void PluginsListDlg::AddPlugins()
void PluginsListDlg::SetPlugins(int sel)
{
String type = _("Unpacker");
AddPluginsToList(L"URL_PACK_UNPACK", type);
for (const auto& event : plugin::UnpackerEventNames)
AddPluginsToList(event.c_str(), type);
type = _("Prediffer");
for (const auto& event : plugin::PredifferEventNames)
AddPluginsToList(event.c_str(), type);
type = _("Editor script");
for (const auto& event : plugin::EditorScriptEventNames)
AddPluginsToList(event.c_str(), type);
m_list.DeleteAllItems();
if (sel == 0)
{
AddPluginsToList(L"URL_PACK_UNPACK");
for (const auto& event : plugin::UnpackerEventNames)
AddPluginsToList(event.c_str());
}
else if (sel == 1)
{
for (const auto& event : plugin::PredifferEventNames)
AddPluginsToList(event.c_str());
}
else if (sel == 2)
{
for (const auto& event : plugin::EditorScriptEventNames)
AddPluginsToList(event.c_str() );
}
}

/**
* @brief Add plugins of given event type to the list.
* @param [in] pluginEvent Event type for plugins to add.
* @param [in] pluginType String to use as type in the list.
*/
void PluginsListDlg::AddPluginsToList(const wchar_t *pluginEvent, const String& pluginType)
void PluginsListDlg::AddPluginsToList(const wchar_t *pluginEvent)
{
PluginArray * piPluginArray =
CAllThreadsScripts::GetActiveSet()->GetAvailableScripts(pluginEvent);
Expand All @@ -146,7 +161,7 @@ void PluginsListDlg::AddPluginsToList(const wchar_t *pluginEvent, const String&
String desc = containsNonAsciiChars ? plugin->m_description : tr(ucr::toUTF8(plugin->m_description));
strutils::replace(desc, _T("\r"), _T(""));
strutils::replace(desc, _T("\n"), _T(" "));
m_list.SetItemText(ind, 1, (pluginType + _T("/") + processType2).c_str());
m_list.SetItemText(ind, 1, processType2.c_str());
m_list.SetItemText(ind, 2, desc.c_str());
m_list.SetCheck(ind, !plugin->m_disabled);
m_list.SetItemData(ind, reinterpret_cast<DWORD_PTR>(plugin.get()));
Expand Down Expand Up @@ -180,8 +195,7 @@ void PluginsListDlg::RefreshList()
auto pos = m_list.GetFirstSelectedItemPosition();
if (pos)
index = m_list.GetNextSelectedItem(pos);
m_list.DeleteAllItems();
AddPlugins();
SetPlugins(m_comboType.GetCurSel());
if (index >= m_list.GetItemCount())
index = m_list.GetItemCount() - 1;
if (index > 0)
Expand All @@ -203,7 +217,10 @@ void PluginsListDlg::AddPlugin(unsigned id)
return;
String errmsg;
if (internal_plugin::AddPlugin(*info, errmsg))
{
m_comboType.SetCurSel(id == ID_PLUGIN_ADD_UNPACKER ? 0 : 1);
break;
}
AfxMessageBox(errmsg.c_str(), MB_OK | MB_ICONEXCLAMATION);
}
RefreshList();
Expand Down Expand Up @@ -410,6 +427,14 @@ void PluginsListDlg::OnLVNItemChanged(NMHDR *pNMHDR, LRESULT *pResult)
}
}

/**
* @brief Prepares multi-selection drop list
*/
void PluginsListDlg::OnSelchangePluginType()
{
SetPlugins(m_comboType.GetCurSel());
}

/**
* @brief Prepares multi-selection drop list
*/
Expand Down
8 changes: 6 additions & 2 deletions Src/PluginsListDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "TrDialogs.h"
#include "UnicodeString.h"
#include "CMoveConstraint.h"

class PluginInfo;
namespace internal_plugin { struct Info; }
Expand All @@ -30,8 +31,8 @@ class PluginsListDlg : public CTrDialog

protected:
void InitList();
void AddPlugins();
void AddPluginsToList(const wchar_t *pluginEvent, const String& pluginType);
void SetPlugins(int sel);
void AddPluginsToList(const wchar_t *pluginEvent);
void RefreshList();
void AddPlugin(unsigned id);
void EditPlugin();
Expand All @@ -55,10 +56,13 @@ class PluginsListDlg : public CTrDialog
afx_msg void OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult);
afx_msg void OnDropDownPatterns();
afx_msg void OnCloseUpPatterns();
afx_msg void OnSelchangePluginType();
afx_msg void OnHelp();
DECLARE_MESSAGE_MAP()

public:
CComboBox m_comboPatterns;
CComboBox m_comboType;
CListCtrl m_list; /**< A list control for plugins. */
prdlg::CMoveConstraint m_constraint; /**< Resizes dialog controls when dialog resized */
};
6 changes: 3 additions & 3 deletions Translations/WinMerge/Arabic.po
Original file line number Diff line number Diff line change
Expand Up @@ -2067,6 +2067,9 @@ msgstr "الإضافات"
msgid "&Enable plugins"
msgstr "تفعيل الإضافات"

msgid "Plugin &type:"
msgstr ""

msgid "File filters:"
msgstr ""

Expand Down Expand Up @@ -2198,9 +2201,6 @@ msgstr "ع&رض بصيغة نظام عد ستة عشري"
msgid "Edit Plugin"
msgstr ""

msgid "Plugin &type:"
msgstr ""

msgid "&Category:"
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/Basque.po
Original file line number Diff line number Diff line change
Expand Up @@ -2516,6 +2516,9 @@ msgstr "Pluginak"
msgid "&Enable plugins"
msgstr "Gaitu &pluginak"

msgid "Plugin &type:"
msgstr ""

msgid "File filters:"
msgstr ""

Expand Down Expand Up @@ -2664,9 +2667,6 @@ msgstr ""
msgid "Edit Plugin"
msgstr ""

msgid "Plugin &type:"
msgstr ""

msgid "&Category:"
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/Brazilian.po
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,9 @@ msgstr "Plugins"
msgid "&Enable plugins"
msgstr "&Ativar plugins"

msgid "Plugin &type:"
msgstr "&Tipo de Plugin:"

msgid "File filters:"
msgstr "Filtros dos arquivo:"

Expand Down Expand Up @@ -2189,9 +2192,6 @@ msgstr "&Visualização Hex"
msgid "Edit Plugin"
msgstr "Editar Plugin"

msgid "Plugin &type:"
msgstr "&Tipo de Plugin:"

msgid "&Category:"
msgstr "&Categoria:"

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/Bulgarian.po
Original file line number Diff line number Diff line change
Expand Up @@ -2063,6 +2063,9 @@ msgstr "Добавки"
msgid "&Enable plugins"
msgstr "Включване на &добавките"

msgid "Plugin &type:"
msgstr ""

msgid "File filters:"
msgstr "Филтри за файлове:"

Expand Down Expand Up @@ -2194,9 +2197,6 @@ msgstr "&Шестнадесетичен изглед"
msgid "Edit Plugin"
msgstr ""

msgid "Plugin &type:"
msgstr ""

msgid "&Category:"
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/Catalan.po
Original file line number Diff line number Diff line change
Expand Up @@ -2521,6 +2521,9 @@ msgstr "&Connectors"
msgid "&Enable plugins"
msgstr "&Habilita els Connectors"

msgid "Plugin &type:"
msgstr ""

msgid "File filters:"
msgstr "Filtres de fitxer:"

Expand Down Expand Up @@ -2669,9 +2672,6 @@ msgstr "Vista &Hexadecimal"
msgid "Edit Plugin"
msgstr ""

msgid "Plugin &type:"
msgstr ""

msgid "&Category:"
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/ChineseSimplified.po
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,9 @@ msgstr "插件"
msgid "&Enable plugins"
msgstr "启用插件(&E)"

msgid "Plugin &type:"
msgstr "插件类型(&T):"

msgid "File filters:"
msgstr "文件过滤器:"

Expand Down Expand Up @@ -2206,9 +2209,6 @@ msgstr "十六进制查看(&H)"
msgid "Edit Plugin"
msgstr "编辑插件"

msgid "Plugin &type:"
msgstr "插件类型(&T):"

msgid "&Category:"
msgstr "类别(&C):"

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/ChineseTraditional.po
Original file line number Diff line number Diff line change
Expand Up @@ -2531,6 +2531,9 @@ msgstr "外掛程式"
msgid "&Enable plugins"
msgstr "啟用外掛程式 (&E)"

msgid "Plugin &type:"
msgstr ""

msgid "File filters:"
msgstr "檔案篩選器:"

Expand Down Expand Up @@ -2679,9 +2682,6 @@ msgstr "二進制顯示 (&H)"
msgid "Edit Plugin"
msgstr ""

msgid "Plugin &type:"
msgstr ""

msgid "&Category:"
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions Translations/WinMerge/Corsican.po
Original file line number Diff line number Diff line change
Expand Up @@ -2068,6 +2068,9 @@ msgstr "Moduli d’estensione"
msgid "&Enable plugins"
msgstr "&Attivà i moduli d’estensione"

msgid "Plugin &type:"
msgstr "Tipu di &modulu d’estensione :"

msgid "File filters:"
msgstr "Filtri di schedariu :"

Expand Down Expand Up @@ -2199,9 +2202,6 @@ msgstr "Vista &esadecimale"
msgid "Edit Plugin"
msgstr "Mudificà u modulu d’estensione"

msgid "Plugin &type:"
msgstr "Tipu di &modulu d’estensione :"

msgid "&Category:"
msgstr "&Categuria :"

Expand Down
Loading

0 comments on commit 2b2ad2a

Please sign in to comment.