Sinced gtkmm2ext needs to get at the actions of widgets, I moved the
action to Gtkmm2ext::Activatable. Not sure if the wisest thing to
do here would be to use Gtkmm::Activatable, but figured there's
a reason Paul didn't do so (the name set_related_action is from there
so presumably it's known about), so this is the simplest change
that allows access to the action in Gtkmm2ext. The vfunc calling
stuff should probably move there as well...
git-svn-id: svn://localhost/ardour2/branches/3.0@10818
d708f5d6-7413-0410-9779-
e7cbd77b26cf
ArdourButton::ArdourButton (Element e)
: _elements (e)
, _tweaks (Tweaks (0))
- , _act_on_release (true)
, _text_width (0)
, _text_height (0)
, _diameter (11.0)
, fill_pattern (0)
, led_inset_pattern (0)
, reflection_pattern (0)
+ , _led_rect (0)
+ , _act_on_release (true)
, _led_left (false)
, _fixed_diameter (true)
, _distinct_led_click (false)
- , _led_rect (0)
, _hovering (false)
{
ColorsChanged.connect (sigc::mem_fun (*this, &ArdourButton::color_handler));
ArdourButton::ArdourButton (const std::string& str, Element e)
: _elements (e)
- , _act_on_release (true)
, _text_width (0)
, _text_height (0)
, _diameter (11.0)
, fill_pattern (0)
, led_inset_pattern (0)
, reflection_pattern (0)
+ , _led_rect (0)
+ , _act_on_release (true)
, _led_left (false)
, _fixed_diameter (true)
, _distinct_led_click (false)
- , _led_rect (0)
, _hovering (false)
{
set_text (str);
void
ArdourButton::set_related_action (RefPtr<Action> act)
{
- _action = act;
+ Gtkmm2ext::Activatable::set_related_action (act);
if (_action) {
- string str = _action->property_tooltip().get_value();
- if (!str.empty()) {
- ARDOUR_UI::instance()->set_tip (*this, str);
- }
+ action_tooltip_changed ();
Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (_action);
if (tact) {
string str = _action->property_tooltip().get_value();
ARDOUR_UI::instance()->set_tip (*this, str);
}
-
#include "pbd/signals.h"
#include "gtkmm2ext/binding_proxy.h"
+#include "gtkmm2ext/activatable.h"
#include "cairo_widget.h"
-class ArdourButton : public CairoWidget
+class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
{
public:
enum Element {
boost::shared_ptr<PBD::Controllable> get_controllable() { return binding_proxy.get_controllable(); }
void set_controllable (boost::shared_ptr<PBD::Controllable> c);
- void watch ();
+ void watch ();
void set_related_action (Glib::RefPtr<Gtk::Action>);
bool on_enter_notify_event (GdkEventCrossing*);
bool on_leave_notify_event (GdkEventCrossing*);
- void controllable_changed ();
- PBD::ScopedConnection watch_connection;
+ void controllable_changed ();
+ PBD::ScopedConnection watch_connection;
private:
Glib::RefPtr<Pango::Layout> _layout;
std::string _text;
Element _elements;
Tweaks _tweaks;
- BindingProxy binding_proxy;
- bool _act_on_release;
+ BindingProxy binding_proxy;
int _text_width;
int _text_height;
cairo_pattern_t* led_inset_pattern;
cairo_pattern_t* reflection_pattern;
+ cairo_rectangle_t* _led_rect;
+
double text_r;
double text_g;
double text_b;
double led_b;
double led_a;
+ bool _act_on_release;
bool _led_left;
bool _fixed_diameter;
bool _distinct_led_click;
- cairo_rectangle_t* _led_rect;
bool _hovering;
void setup_led_rect ();
void set_colors ();
void color_handler ();
- Glib::RefPtr<Gtk::Action> _action;
- void action_activated ();
void action_toggled ();
void action_sensitivity_changed ();
#include <gtkmm2ext/utils.h>
#include <gtkmm2ext/window_title.h>
#include <gtkmm2ext/actions.h>
+#include <gtkmm2ext/activatable.h>
#include "i18n.h"
std::string msg(tip);
Glib::RefPtr<Gtk::Action> action = w->get_action();
+
+ if (!action) {
+ Gtkmm2ext::Activatable* activatable;
+ if ((activatable = dynamic_cast<Gtkmm2ext::Activatable*>(w))) {
+ action = activatable->get_related_action();
+ }
+ }
+
if (action) {
Gtk::AccelKey key;
- ustring ap = action->get_accel_path();
- if (!ap.empty()) {
- bool has_key = ActionManager::lookup_entry(ap, key);
- if (has_key && key.get_abbrev() != "") {
- msg.append("\n\n Key: ").append(key.get_abbrev());
- }
- }
+ ustring ap = action->get_accel_path();
+ if (!ap.empty()) {
+ bool has_key = ActionManager::lookup_entry(ap, key);
+ if (has_key && key.get_abbrev() != "") {
+ msg.append("\n\nKey: ").append(key.get_abbrev());
+ }
+ }
}
if (req == 0) {
--- /dev/null
+/*
+ Copyright (C) 2011 Paul Davis
+ Author: David Robillard
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __libgtkmm2ext_activatable_h__
+#define __libgtkmm2ext_activatable_h__
+
+#include <gtkmm/action.h>
+
+namespace Gtkmm2ext {
+
+/**
+ A Widget with an associated Action.
+
+ Gtkmm itself has a class for this. I don't know why we don't use it.
+*/
+class Activatable {
+public:
+ virtual ~Activatable() {}
+
+ virtual void set_related_action(Glib::RefPtr<Gtk::Action> a) {
+ _action = a;
+ }
+
+ Glib::RefPtr<Gtk::Action> get_related_action() {
+ return _action;
+ }
+
+protected:
+ Glib::RefPtr<Gtk::Action> _action;
+};
+
+} /* namespace */
+
+#endif /* __libgtkmm2ext_actions_h__ */