diff --git a/include/controller/callbacks_internal.h b/include/controller/callbacks_internal.h index 1438c6e..b14af9d 100644 --- a/include/controller/callbacks_internal.h +++ b/include/controller/callbacks_internal.h @@ -23,4 +23,7 @@ Ihandle *get_current_list(Ihandle *dlg); // 刷新撤销/重做按钮的启用状态 void refresh_undo_redo_buttons(Ihandle *dlg); +// 同步合并预览列表 +void sync_merged_list(Ihandle *dlg); + #endif // CALLBACKS_INTERNAL_H diff --git a/include/utils/ui_constants.h b/include/utils/ui_constants.h index ecf89e8..b052aa8 100644 --- a/include/utils/ui_constants.h +++ b/include/utils/ui_constants.h @@ -10,6 +10,7 @@ // 列表控件 #define CTRL_LIST_SYS "LIST_SYS" #define CTRL_LIST_USER "LIST_USER" +#define CTRL_LIST_MERGED "LIST_MERGED" // 选项卡 #define CTRL_TABS_MAIN "TABS_MAIN" diff --git a/locale/en_US/LC_MESSAGES/en_US.mo b/locale/en_US/LC_MESSAGES/en_US.mo index c60b283..439c72f 100644 Binary files a/locale/en_US/LC_MESSAGES/en_US.mo and b/locale/en_US/LC_MESSAGES/en_US.mo differ diff --git a/locale/zh_CN/LC_MESSAGES/zh_CN.mo b/locale/zh_CN/LC_MESSAGES/zh_CN.mo index 870d568..375f38b 100644 Binary files a/locale/zh_CN/LC_MESSAGES/zh_CN.mo and b/locale/zh_CN/LC_MESSAGES/zh_CN.mo differ diff --git a/lua/config.lua b/lua/config.lua index 8e216ff..5d7ca2b 100644 --- a/lua/config.lua +++ b/lua/config.lua @@ -51,6 +51,7 @@ local config = { search_placeholder = "Search...", tab_sys = "System Variables", tab_user = "User Variables", + tab_merged = "Merged Preview", export_title = "Export PATH", import_title = "Import PATH" }, diff --git a/po/en_US.po b/po/en_US.po index 4d985e1..7bb3616 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -28,6 +28,10 @@ msgstr "System Variables" msgid "User Variables" msgstr "User Variables" +#: src/ui/main_window.c +msgid "Merged Preview" +msgstr "Merged Preview" + #: src/ui/main_window.c msgid "New" msgstr "New" diff --git a/po/messages.pot b/po/messages.pot index b5acaa8..69dbf35 100644 --- a/po/messages.pot +++ b/po/messages.pot @@ -29,6 +29,10 @@ msgstr "" msgid "User Variables" msgstr "" +#: src/ui/main_window.c +msgid "Merged Preview" +msgstr "" + #: src/ui/main_window.c msgid "New" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 5a693dd..8412ab6 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -28,6 +28,10 @@ msgstr "系统变量" msgid "User Variables" msgstr "用户变量" +#: src/ui/main_window.c +msgid "Merged Preview" +msgstr "合并预览" + #: src/ui/main_window.c msgid "New" msgstr "新建" diff --git a/src/controller/callbacks.c b/src/controller/callbacks.c index fc8fa35..26dc8c0 100644 --- a/src/controller/callbacks.c +++ b/src/controller/callbacks.c @@ -3,6 +3,7 @@ #include "core/app_context.h" #include "core/undo_redo.h" #include "utils/ui_constants.h" +#include "ui/ui_utils.h" #include // 辅助函数:获取主对话框 @@ -62,3 +63,24 @@ void refresh_undo_redo_buttons(Ihandle *dlg) if (btn_redo) IupSetAttribute(btn_redo, "ACTIVE", can_redo(ctx->undo_redo_mgr) ? "YES" : "NO"); } + +// 同步合并预览列表(sys + user) +void sync_merged_list(Ihandle *dlg) +{ + AppContext *ctx = get_app_context_from_dlg(dlg); + Ihandle *list_merged = IupGetDialogChild(dlg, CTRL_LIST_MERGED); + if (!ctx || !list_merged) + return; + + IupSetAttribute(list_merged, "REMOVEITEM", "ALL"); + + int pos = 1; + for (int i = 0; i < ctx->sys_paths.count; i++) + IupSetAttributeId(list_merged, "", pos++, string_list_get(&ctx->sys_paths, i)); + for (int i = 0; i < ctx->user_paths.count; i++) + IupSetAttributeId(list_merged, "", pos++, string_list_get(&ctx->user_paths, i)); + + int total = ctx->sys_paths.count + ctx->user_paths.count; + IupSetInt(list_merged, "COUNT", total); + refresh_single_list_style(list_merged); +} diff --git a/src/controller/callbacks_sys.c b/src/controller/callbacks_sys.c index f1c8de8..e13ba7f 100644 --- a/src/controller/callbacks_sys.c +++ b/src/controller/callbacks_sys.c @@ -164,6 +164,7 @@ void load_all_paths(void) sync_string_list_to_ui(list_sys, &ctx->sys_paths); sync_string_list_to_ui(list_user, &ctx->user_paths); + sync_merged_list(dlg); Ihandle *lbl_status = IupGetDialogChild(dlg, CTRL_LBL_STATUS); if (lbl_status) diff --git a/src/ui/main_window.c b/src/ui/main_window.c index 10a5e39..f710758 100644 --- a/src/ui/main_window.c +++ b/src/ui/main_window.c @@ -1,5 +1,6 @@ #include "ui/main_window.h" #include "controller/callbacks.h" +#include "controller/callbacks_internal.h" #include "core/lua_config.h" #include "utils/i18n.h" #include "utils/ui_constants.h" @@ -24,6 +25,16 @@ static Ihandle *create_path_list(const char *name) return list; } +// 选项卡切换回调:切换到合并预览时刷新列表 +static int tab_change_cb(Ihandle *self, Ihandle *new_tab, Ihandle *old_tab) +{ + (void)old_tab; + (void)new_tab; + Ihandle *dlg = IupGetDialog(self); + sync_merged_list(dlg); + return IUP_DEFAULT; +} + // 创建主窗口 Ihandle *create_main_window(void) { @@ -31,6 +42,15 @@ Ihandle *create_main_window(void) Ihandle *list_sys = create_path_list(CTRL_LIST_SYS); // 创建用户路径列表 Ihandle *list_user = create_path_list(CTRL_LIST_USER); + // 创建合并预览列表(只读) + Ihandle *list_merged = IupFlatList(); + IupSetAttribute(list_merged, "NAME", CTRL_LIST_MERGED); + IupSetAttribute(list_merged, "EXPAND", "YES"); + IupSetAttribute(list_merged, "ITEMPADDING", lua_config_get_string("list", "item_padding")); + IupSetAttribute(list_merged, "BACKCOLOR", lua_config_get_string("list", "backcolor")); + IupSetAttribute(list_merged, "BORDER", "YES"); + IupSetAttribute(list_merged, "HLINE", "NO"); + IupSetAttribute(list_merged, "ACTIVE", "NO"); // 只读 // 创建搜索框 Ihandle *txt_search = IupText(NULL); @@ -43,11 +63,14 @@ Ihandle *create_main_window(void) Ihandle *tabs_main = IupTabs( IupVbox(list_sys, NULL), IupVbox(list_user, NULL), + IupVbox(list_merged, NULL), NULL); IupSetAttribute(tabs_main, "NAME", CTRL_TABS_MAIN); IupSetAttribute(tabs_main, "TABTITLE0", _(lua_config_get_string("label", "tab_sys"))); IupSetAttribute(tabs_main, "TABTITLE1", _(lua_config_get_string("label", "tab_user"))); + IupSetAttribute(tabs_main, "TABTITLE2", _(lua_config_get_string("label", "tab_merged"))); IupSetAttribute(tabs_main, "TABTYPE", "TOP"); + IupSetCallback(tabs_main, "TABCHANGE_CB", (Icallback)tab_change_cb); // 创建操作按钮 Ihandle *btn_new = IupButton(_(lua_config_get_string("button", "new")), NULL); @@ -201,6 +224,7 @@ void refresh_main_window_ui(Ihandle *main_dlg) { IupSetAttribute(tabs, "TABTITLE0", _(lua_config_get_string("label", "tab_sys"))); IupSetAttribute(tabs, "TABTITLE1", _(lua_config_get_string("label", "tab_user"))); + IupSetAttribute(tabs, "TABTITLE2", _(lua_config_get_string("label", "tab_merged"))); } // 辅助函数:设置子控件标题