feat(modulo): make search bar hint configurable
This commit is contained in:
parent
eb7474763b
commit
96ce9090f8
|
@ -48,6 +48,9 @@ pub struct SearchConfig {
|
||||||
|
|
||||||
#[serde(default = "default_algorithm")]
|
#[serde(default = "default_algorithm")]
|
||||||
pub algorithm: String,
|
pub algorithm: String,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub hint: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
|
|
@ -36,5 +36,6 @@ pub fn generate(config: SearchConfig) -> types::Search {
|
||||||
title: config.title,
|
title: config.title,
|
||||||
items,
|
items,
|
||||||
icon: config.icon,
|
icon: config.icon,
|
||||||
|
hint: config.hint,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,7 @@ typedef struct SearchResults {
|
||||||
typedef struct SearchMetadata {
|
typedef struct SearchMetadata {
|
||||||
const char *windowTitle;
|
const char *windowTitle;
|
||||||
const char *iconPath;
|
const char *iconPath;
|
||||||
|
const char *hintText;
|
||||||
} SearchMetadata;
|
} SearchMetadata;
|
||||||
|
|
||||||
// WIZARD
|
// WIZARD
|
||||||
|
|
|
@ -105,6 +105,7 @@ pub struct SearchResults {
|
||||||
pub struct SearchMetadata {
|
pub struct SearchMetadata {
|
||||||
pub windowTitle: *const ::std::os::raw::c_char,
|
pub windowTitle: *const ::std::os::raw::c_char,
|
||||||
pub iconPath: *const ::std::os::raw::c_char,
|
pub iconPath: *const ::std::os::raw::c_char,
|
||||||
|
pub hintText: *const ::std::os::raw::c_char,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const WIZARD_MIGRATE_RESULT_SUCCESS: i32 = 0;
|
pub const WIZARD_MIGRATE_RESULT_SUCCESS: i32 = 0;
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub mod types {
|
||||||
pub struct Search {
|
pub struct Search {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub icon: Option<String>,
|
pub icon: Option<String>,
|
||||||
|
pub hint: Option<String>,
|
||||||
pub items: Vec<SearchItem>,
|
pub items: Vec<SearchItem>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +47,7 @@ mod interop {
|
||||||
pub(crate) struct OwnedSearch {
|
pub(crate) struct OwnedSearch {
|
||||||
title: CString,
|
title: CString,
|
||||||
icon_path: CString,
|
icon_path: CString,
|
||||||
|
hint: CString,
|
||||||
items: Vec<OwnedSearchItem>,
|
items: Vec<OwnedSearchItem>,
|
||||||
pub(crate) interop_items: Vec<SearchItem>,
|
pub(crate) interop_items: Vec<SearchItem>,
|
||||||
_interop: Box<SearchMetadata>,
|
_interop: Box<SearchMetadata>,
|
||||||
|
@ -80,18 +82,27 @@ mod interop {
|
||||||
std::ptr::null()
|
std::ptr::null()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let hint = if let Some(hint) = search.hint.as_ref() {
|
||||||
|
hint.clone()
|
||||||
|
} else {
|
||||||
|
"".to_owned()
|
||||||
|
};
|
||||||
|
|
||||||
|
let hint = CString::new(hint).expect("unable to convert search icon to CString");
|
||||||
|
|
||||||
|
let hint_ptr = if search.hint.is_some() {
|
||||||
|
hint.as_ptr()
|
||||||
|
} else {
|
||||||
|
std::ptr::null()
|
||||||
|
};
|
||||||
|
|
||||||
let _interop = Box::new(SearchMetadata {
|
let _interop = Box::new(SearchMetadata {
|
||||||
iconPath: icon_path_ptr,
|
iconPath: icon_path_ptr,
|
||||||
windowTitle: title.as_ptr(),
|
windowTitle: title.as_ptr(),
|
||||||
|
hintText: hint_ptr,
|
||||||
});
|
});
|
||||||
|
|
||||||
Self {
|
Self { title, icon_path, hint, items, interop_items, _interop }
|
||||||
title,
|
|
||||||
items,
|
|
||||||
icon_path,
|
|
||||||
interop_items,
|
|
||||||
_interop,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,11 +222,13 @@ SearchFrame::SearchFrame(const wxString &title, const wxPoint &pos, const wxSize
|
||||||
|
|
||||||
vbox->Add(topBox, 1, wxEXPAND);
|
vbox->Add(topBox, 1, wxEXPAND);
|
||||||
|
|
||||||
helpText = new wxStaticText(panel, wxID_ANY, "Search matches by content or trigger (or type > to see commands)");
|
if (searchMetadata->hintText) {
|
||||||
|
helpText = new wxStaticText(panel, wxID_ANY, wxString::FromUTF8(searchMetadata->hintText));
|
||||||
vbox->Add(helpText, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
vbox->Add(helpText, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
|
||||||
wxFont helpFont = helpText->GetFont();
|
wxFont helpFont = helpText->GetFont();
|
||||||
helpFont.SetPointSize(HELP_TEXT_FONT_SIZE);
|
helpFont.SetPointSize(HELP_TEXT_FONT_SIZE);
|
||||||
helpText->SetFont(helpFont);
|
helpText->SetFont(helpFont);
|
||||||
|
}
|
||||||
|
|
||||||
wxArrayString choices;
|
wxArrayString choices;
|
||||||
int resultId = NewControlId();
|
int resultId = NewControlId();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user