diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-04-15 18:04:23 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-04-15 18:04:23 +0000 |
commit | 54d9f2f2d83af1f0f44579fe2ebf090e68259938 (patch) | |
tree | 44a61c36048be6edabeb5fc5461d47c95623f79f /libs/gtkmm2ext | |
parent | ece2bacb2c7d7f72b6a25a75760837efce0d5e30 (diff) |
first half of the mega-by-hand-commit-by-commit merge from 2.X
git-svn-id: svn://localhost/ardour2/branches/3.0@4980 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/utils.h | 13 | ||||
-rw-r--r-- | libs/gtkmm2ext/sync-menu.c | 15 | ||||
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 42 |
3 files changed, 54 insertions, 16 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h index e664f2420d..7f986e738c 100644 --- a/libs/gtkmm2ext/gtkmm2ext/utils.h +++ b/libs/gtkmm2ext/gtkmm2ext/utils.h @@ -45,12 +45,21 @@ namespace Gtkmm2ext { gint vpadding); void set_size_request_to_display_given_text (Gtk::Widget &w, - const std::vector<std::string>&, + const std::vector<std::string>&, gint hpadding, gint vpadding); void set_popdown_strings (Gtk::ComboBoxText&, - const std::vector<std::string>&); + const std::vector<std::string>&, + bool set_size = false, + gint hpadding = 0, gint vpadding = 0); + + // Combo's are stupid - they steal space from the entry for the button +#ifdef GTKOSX + static const guint32 COMBO_FUDGE = 38; +#else + static const guint32 COMBO_FUDGE = 24; +#endif template<class T> void deferred_delete (void *ptr) { delete static_cast<T *> (ptr); diff --git a/libs/gtkmm2ext/sync-menu.c b/libs/gtkmm2ext/sync-menu.c index 894446c424..a16babce54 100644 --- a/libs/gtkmm2ext/sync-menu.c +++ b/libs/gtkmm2ext/sync-menu.c @@ -313,6 +313,7 @@ carbon_menu_item_update_accelerator (CarbonMenuItem *carbon_item, gint n_keys; gint use_command; gboolean add_modifiers = FALSE; + UInt8 modifiers = 0; /* implies Command key */ if (gdk_keymap_get_entries_for_keyval (keymap, key->accel_key, &keys, &n_keys) == 0) @@ -347,10 +348,14 @@ carbon_menu_item_update_accelerator (CarbonMenuItem *carbon_item, } } else { - SetMenuItemCommandKey (carbon_item->menu, carbon_item->index, - true, keys[0].keycode); - g_free (keys); - add_modifiers = TRUE; + SetMenuItemCommandKey (carbon_item->menu, carbon_item->index, true, keys[0].keycode); + if (keys[0].level == 1) { + /* regular key, but it needs shift to make it work */ + modifiers |= kMenuShiftModifier; + } + + g_free (keys); + add_modifiers = TRUE; } if (add_modifiers) @@ -589,7 +594,7 @@ menu_event_handler_func (EventHandlerCallRef event_handler_call_ref, sizeof (widget), 0, &widget); if (err == noErr && GTK_IS_WIDGET (widget)) { - g_idle_add (dummy_gtk_menu_item_activate, widget); + g_idle_add ((GSourceFunc) dummy_gtk_menu_item_activate, widget); // gtk_menu_item_activate (GTK_MENU_ITEM (widget)); _in_carbon_menu_event_handler = 0; return noErr; diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index adcaaaaeb5..3a021bbe7b 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -59,8 +59,8 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, const gchar * void Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, - const std::vector<std::string>& strings, - gint hpadding, gint vpadding) + const std::vector<std::string>& strings, + gint hpadding, gint vpadding) { int width, height; @@ -68,11 +68,10 @@ Gtkmm2ext::set_size_request_to_display_given_text (Gtk::Widget &w, int height_max = 0; w.ensure_style (); - for (vector<string>::const_iterator i = strings.begin(); - i != strings.end(); ++i) { - get_ink_pixel_size (w.create_pango_layout (*i), width, height); - width_max = max(width_max,width); - height_max = max(height_max, height); + for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) { + get_ink_pixel_size (w.create_pango_layout (*i), width, height); + width_max = max(width_max,width); + height_max = max(height_max, height); } w.set_size_request(width_max + hpadding, height_max + vpadding); } @@ -85,11 +84,36 @@ Gtkmm2ext::init () } void -Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings) +Gtkmm2ext::set_popdown_strings (Gtk::ComboBoxText& cr, const vector<string>& strings, bool set_size, gint hpadding, gint vpadding) { + vector<string>::const_iterator i; + cr.clear (); - for (vector<string>::const_iterator i = strings.begin(); i != strings.end(); ++i) { + if (set_size) { + vector<string> copy; + + for (i = strings.begin(); i != strings.end(); ++i) { + if ((*i).find_first_of ("gy") != string::npos) { + /* contains a descender */ + break; + } + } + + if (i == strings.end()) { + + /* make a copy of the strings then add one that has a descener */ + + copy = strings; + copy.push_back ("g"); + set_size_request_to_display_given_text (cr, copy, COMBO_FUDGE+10+hpadding, 15+vpadding); + + } else { + set_size_request_to_display_given_text (cr, strings, COMBO_FUDGE+10+hpadding, 15+vpadding); + } + } + + for (i = strings.begin(); i != strings.end(); ++i) { cr.append_text (*i); } } |