13
0

move show_gdk_event_state() utility function from gtk2_ardour to libs/gtkmm2ext

This commit is contained in:
Paul Davis 2016-07-18 14:41:25 -04:00
parent 653b113607
commit 1a55e83e98
6 changed files with 62 additions and 119 deletions

View File

@ -5536,7 +5536,7 @@ ARDOUR_UI::key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey
DEBUG_TRACE (DEBUG::Accelerators, string_compose ("Win = %1 [title = %9] focus = %7 (%8) Key event: code = %2 state = %3 special handling ? %4 magic widget focus ? %5 focus widget %6 named %7 mods ? %8\n",
win,
ev->keyval,
show_gdk_event_state (ev->state),
Gtkmm2ext::show_gdk_event_state (ev->state),
special_handling_of_unmodified_accelerators,
Keyboard::some_magic_widget_has_focus(),
focus,

View File

@ -350,65 +350,6 @@ ARDOUR_UI_UTILS::emulate_key_event (unsigned int keyval)
return relay_key_press(&ev, &main_window);
}
string
ARDOUR_UI_UTILS::show_gdk_event_state (int state)
{
string s;
if (state & GDK_SHIFT_MASK) {
s += "+SHIFT";
}
if (state & GDK_LOCK_MASK) {
s += "+LOCK";
}
if (state & GDK_CONTROL_MASK) {
s += "+CONTROL";
}
if (state & GDK_MOD1_MASK) {
s += "+MOD1";
}
if (state & GDK_MOD2_MASK) {
s += "+MOD2";
}
if (state & GDK_MOD3_MASK) {
s += "+MOD3";
}
if (state & GDK_MOD4_MASK) {
s += "+MOD4";
}
if (state & GDK_MOD5_MASK) {
s += "+MOD5";
}
if (state & GDK_BUTTON1_MASK) {
s += "+BUTTON1";
}
if (state & GDK_BUTTON2_MASK) {
s += "+BUTTON2";
}
if (state & GDK_BUTTON3_MASK) {
s += "+BUTTON3";
}
if (state & GDK_BUTTON4_MASK) {
s += "+BUTTON4";
}
if (state & GDK_BUTTON5_MASK) {
s += "+BUTTON5";
}
if (state & GDK_SUPER_MASK) {
s += "+SUPER";
}
if (state & GDK_HYPER_MASK) {
s += "+HYPER";
}
if (state & GDK_META_MASK) {
s += "+META";
}
if (state & GDK_RELEASE_MASK) {
s += "+RELEASE";
}
return s;
}
Glib::RefPtr<Gdk::Pixbuf>
ARDOUR_UI_UTILS::get_xpm (std::string name)
{

View File

@ -96,7 +96,6 @@ std::string rate_as_string (float r);
bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
bool overwrite_file_dialog (Gtk::Window& parent, std::string title, std::string text);
std::string show_gdk_event_state (int state);
bool running_from_source_tree ();
} // namespace

View File

@ -175,6 +175,8 @@ namespace Gtkmm2ext {
LIBGTKMM2EXT_API float paned_position_as_fraction (Gtk::Paned& paned, bool h);
LIBGTKMM2EXT_API void paned_set_position_as_fraction (Gtk::Paned& paned, float fraction, bool h);
LIBGTKMM2EXT_API std::string show_gdk_event_state (int state);
};
#endif /* __gtkmm2ext_utils_h__ */

View File

@ -42,6 +42,7 @@
#include "gtkmm2ext/bindings.h"
#include "gtkmm2ext/keyboard.h"
#include "gtkmm2ext/debug.h"
#include "gtkmm2ext/utils.h"
#include "pbd/i18n.h"
@ -272,64 +273,6 @@ Keyboard::_snooper (GtkWidget *widget, GdkEventKey *event, gpointer data)
return ((Keyboard *) data)->snooper (widget, event);
}
static string
show_gdk_event_state (int state)
{
string s;
if (state & GDK_SHIFT_MASK) {
s += "+SHIFT";
}
if (state & GDK_LOCK_MASK) {
s += "+LOCK";
}
if (state & GDK_CONTROL_MASK) {
s += "+CONTROL";
}
if (state & GDK_MOD1_MASK) {
s += "+MOD1";
}
if (state & GDK_MOD2_MASK) {
s += "+MOD2";
}
if (state & GDK_MOD3_MASK) {
s += "+MOD3";
}
if (state & GDK_MOD4_MASK) {
s += "+MOD4";
}
if (state & GDK_MOD5_MASK) {
s += "+MOD5";
}
if (state & GDK_BUTTON1_MASK) {
s += "+BUTTON1";
}
if (state & GDK_BUTTON2_MASK) {
s += "+BUTTON2";
}
if (state & GDK_BUTTON3_MASK) {
s += "+BUTTON3";
}
if (state & GDK_BUTTON4_MASK) {
s += "+BUTTON4";
}
if (state & GDK_BUTTON5_MASK) {
s += "+BUTTON5";
}
if (state & GDK_SUPER_MASK) {
s += "+SUPER";
}
if (state & GDK_HYPER_MASK) {
s += "+HYPER";
}
if (state & GDK_META_MASK) {
s += "+META";
}
if (state & GDK_RELEASE_MASK) {
s += "+RELEASE";
}
return s;
}
gint
Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)

View File

@ -1012,3 +1012,61 @@ Gtkmm2ext::paned_set_position_as_fraction (Gtk::Paned& paned, float fraction, bo
paned.set_position ((guint) floor (fraction * v));
}
string
Gtkmm2ext::show_gdk_event_state (int state)
{
string s;
if (state & GDK_SHIFT_MASK) {
s += "+SHIFT";
}
if (state & GDK_LOCK_MASK) {
s += "+LOCK";
}
if (state & GDK_CONTROL_MASK) {
s += "+CONTROL";
}
if (state & GDK_MOD1_MASK) {
s += "+MOD1";
}
if (state & GDK_MOD2_MASK) {
s += "+MOD2";
}
if (state & GDK_MOD3_MASK) {
s += "+MOD3";
}
if (state & GDK_MOD4_MASK) {
s += "+MOD4";
}
if (state & GDK_MOD5_MASK) {
s += "+MOD5";
}
if (state & GDK_BUTTON1_MASK) {
s += "+BUTTON1";
}
if (state & GDK_BUTTON2_MASK) {
s += "+BUTTON2";
}
if (state & GDK_BUTTON3_MASK) {
s += "+BUTTON3";
}
if (state & GDK_BUTTON4_MASK) {
s += "+BUTTON4";
}
if (state & GDK_BUTTON5_MASK) {
s += "+BUTTON5";
}
if (state & GDK_SUPER_MASK) {
s += "+SUPER";
}
if (state & GDK_HYPER_MASK) {
s += "+HYPER";
}
if (state & GDK_META_MASK) {
s += "+META";
}
if (state & GDK_RELEASE_MASK) {
s += "+RELEASE";
}
return s;
}