Replace positioning function with popup helper
Because all uses of the function positioning menus anchored to a widget were as callback argument to Gtk::Menu::popup() where the caller needed to correctly bind arguments, this led to repeated and a bit obscure code. Wrap the logic into an helper function that takes care of all that, and update the callers.
This commit is contained in:
@@ -97,10 +97,10 @@ namespace Gtkmm2ext {
|
||||
int clip_height,
|
||||
Gdk::Color fg);
|
||||
|
||||
LIBGTKMM2EXT_API void position_menu_anchored (const Gtk::Menu* const menu,
|
||||
Gtk::Widget* const anchor,
|
||||
const std::string& selected,
|
||||
int& x, int& y, bool& push_in);
|
||||
LIBGTKMM2EXT_API void anchored_menu_popup (Gtk::Menu* const menu,
|
||||
Gtk::Widget* const anchor,
|
||||
const std::string& selected,
|
||||
guint button, guint32 time);
|
||||
|
||||
LIBGTKMM2EXT_API void set_popdown_strings (Gtk::ComboBoxText&,
|
||||
const std::vector<std::string>&);
|
||||
|
||||
@@ -310,10 +310,10 @@ Gtkmm2ext::pixbuf_from_string(const string& name, const Pango::FontDescription&
|
||||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::position_menu_anchored (const Gtk::Menu* const menu,
|
||||
_position_menu_anchored (int& x, int& y, bool& push_in,
|
||||
const Gtk::Menu* const menu,
|
||||
Gtk::Widget* const anchor,
|
||||
const std::string& selected,
|
||||
int& x, int& y, bool& push_in) {
|
||||
const std::string& selected) {
|
||||
using namespace Gdk;
|
||||
using namespace Gtk;
|
||||
using namespace Gtk::Menu_Helpers;
|
||||
@@ -416,6 +416,18 @@ Gtkmm2ext::position_menu_anchored (const Gtk::Menu* const menu,
|
||||
push_in = false;
|
||||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::anchored_menu_popup (Gtk::Menu* const menu,
|
||||
Gtk::Widget* const anchor,
|
||||
const std::string& selected,
|
||||
guint button, guint32 time) {
|
||||
menu->popup(
|
||||
sigc::bind (sigc::ptr_fun(&_position_menu_anchored),
|
||||
menu, anchor, selected),
|
||||
button,
|
||||
time);
|
||||
}
|
||||
|
||||
void
|
||||
Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user