Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4584 revisited. Gtk-CRITICAL fixes + resizing and initialization #13092

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/slic3r/GUI/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/slic3r/GUI/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
36 changes: 22 additions & 14 deletions src/slic3r/GUI/PresetComboBoxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<GtkCellRendererText *>(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
}

Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 11 additions & 4 deletions src/slic3r/GUI/TopBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
});

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/TopBar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class TopBarItemsCtrl : public wxControl
void UnselectPopupButtons();

void CreateSearch();
void TriggerSearch();
void ShowFull();
void ShowJustMode();
void SetSettingsButtonTooltip(const wxString& tooltip);
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Widgets/TextInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
}
Expand Down