diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 63ff77dbad9..7cda9889a60 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1537,7 +1537,10 @@ void MainFrame::init_menubar_as_editor() editMenu->AppendSeparator(); append_menu_item(editMenu, wxID_ANY, _L("Searc&h") + "\tCtrl+F", - _L("Search in settings"), [](wxCommandEvent&) { wxGetApp().show_search_dialog(); }, + _L("Search in settings"), [this](wxCommandEvent&) { +// wxGetApp().show_search_dialog(); + m_tabpanel->GetTopBarItemsCtrl()->TriggerSearch(); + }, "search", nullptr, []() {return true; }, this); } @@ -2264,7 +2267,8 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe) #else /* __APPLE__ */ case WXK_CONTROL_F: #endif /* __APPLE__ */ - case 'F': { wxGetApp().show_search_dialog(); break; } + case 'F': { m_tabpanel->GetTopBarItemsCtrl()->TriggerSearch(); + break; } default:break; } } diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 1e7f811269b..e84ed7e582e 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -135,13 +135,13 @@ void PreferencesDialog::show(const std::string& highlight_opt_key /*= std::strin downloader->set_path_name(app_config->get("url_downloader_dest")); downloader->allow(!app_config->has("downloader_url_registered") || app_config->get_bool("downloader_url_registered")); - for (const std::string& opt_key : {"suppress_hyperlinks", "downloader_url_registered", "show_login_button"}) + for (const std::string opt_key : {"suppress_hyperlinks", "downloader_url_registered", "show_login_button"}) m_optgroup_other->set_value(opt_key, app_config->get_bool(opt_key)); // by default "Log in" button is visible if (!app_config->has("show_login_button")) m_optgroup_other->set_value("show_login_button", true); - for (const std::string& opt_key : { "default_action_on_close_application" + for (const std::string opt_key : { "default_action_on_close_application" ,"default_action_on_new_project" ,"default_action_on_select_preset" }) m_optgroup_general->set_value(opt_key, app_config->get(opt_key) == "none"); diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 6b3aea7f6d3..5e74a8c3e78 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -216,20 +216,28 @@ void PresetComboBox::update_selection() // A workaround for a set of issues related to text fitting into gtk widgets: // See e.g.: https://github.com/prusa3d/PrusaSlicer/issues/4584 #if defined(__WXGTK20__) || defined(__WXGTK3__) - GList* cells = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(m_widget)); - - // 'cells' contains the GtkCellRendererPixBuf for the icon, - // 'cells->next' contains GtkCellRendererText for the text we need to ellipsize - if (!cells || !cells->next) return; - - auto cell = static_cast(cells->next->data); - - if (!cell) return; - - g_object_set(G_OBJECT(cell), "ellipsize", PANGO_ELLIPSIZE_END, (char*)NULL); - - // Only the list of cells must be freed, the renderer isn't ours to free - g_list_free(cells); + GtkWidget* widget = m_widget; + if (GTK_IS_CONTAINER(widget)) { + GList* children = gtk_container_get_children(GTK_CONTAINER(widget)); + if (children) { + widget = GTK_WIDGET(children->data); + g_list_free(children); + } + } + if (GTK_IS_ENTRY(widget)) { + // Set ellipsization for the entry + gtk_entry_set_width_chars(GTK_ENTRY(widget), 20); // Adjust this value as needed + gtk_entry_set_max_width_chars(GTK_ENTRY(widget), 20); // Adjust this value as needed + // Create a PangoLayout for the entry and set ellipsization + PangoLayout* layout = gtk_entry_get_layout(GTK_ENTRY(widget)); + if (layout) { + pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); + } else { + g_warning("Unable to get PangoLayout from GtkEntry"); + } + } else { + g_warning("Expected GtkEntry, but got %s", G_OBJECT_TYPE_NAME(widget)); + } #endif } diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index d16e784c1b1..45415e8090d 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -490,6 +490,7 @@ void OptionsSearcher::show_dialog(bool show /*= true*/) search_dialog->Popup(); if (!search_input->HasFocus()) search_input->SetFocus(); + wxYield(); } void OptionsSearcher::dlg_sys_color_changed() diff --git a/src/slic3r/GUI/TopBar.cpp b/src/slic3r/GUI/TopBar.cpp index bed2e15fece..230091d3b3a 100644 --- a/src/slic3r/GUI/TopBar.cpp +++ b/src/slic3r/GUI/TopBar.cpp @@ -292,8 +292,7 @@ void TopBarItemsCtrl::CreateSearch() m_search->SetOnDropDownIcon([this]() { - wxGetApp().searcher().set_search_input(m_search); - wxGetApp().show_search_dialog(); + TriggerSearch(); }); m_search->Bind(wxEVT_KILL_FOCUS, [](wxFocusEvent& e) @@ -317,8 +316,7 @@ void TopBarItemsCtrl::CreateSearch() ctrl->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) { - wxGetApp().searcher().set_search_input(m_search); - wxGetApp().show_search_dialog(); + TriggerSearch(); event.Skip(); }); @@ -330,6 +328,15 @@ void TopBarItemsCtrl::CreateSearch() }); } +void TopBarItemsCtrl::TriggerSearch() +{ + if (m_search && m_search->GetTextCtrl()) + { + wxGetApp().searcher().set_search_input(m_search); + wxGetApp().show_search_dialog(); + } +} + void TopBarItemsCtrl::UpdateSearchSizeAndPosition() { if (!m_workspace_btn || !m_account_btn) diff --git a/src/slic3r/GUI/TopBar.hpp b/src/slic3r/GUI/TopBar.hpp index 596795d97f9..04c17f72d18 100644 --- a/src/slic3r/GUI/TopBar.hpp +++ b/src/slic3r/GUI/TopBar.hpp @@ -90,6 +90,7 @@ class TopBarItemsCtrl : public wxControl void UnselectPopupButtons(); void CreateSearch(); + void TriggerSearch(); void ShowFull(); void ShowJustMode(); void SetSettingsButtonTooltip(const wxString& tooltip); diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 6752991cb3c..231d1553676 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -253,6 +253,7 @@ void TextInput::DoSetSize(int x, int y, int width, int height, int sizeFlags) wxClientDC dc(this); const int r_shift = int(dd_icon_size.x == 0 ? (3. * dc.GetContentScaleFactor()) : ((size.y - dd_icon_size.y) / 2)); textSize.x = size.x - textPos.x - labelSize.x - dd_icon_size.x - r_shift; + if (textSize.x < -1) textSize.x = -1; text_ctrl->SetSize(textSize); text_ctrl->SetPosition({textPos.x, (size.y - textSize.y) / 2}); }