summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-07-08 01:56:11 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-07-08 01:56:11 +0000
commit49efde87b3c658385e2f06b2b662308b5982c710 (patch)
tree2a290ec6b9385465667a48477c87ace2deaa2a61 /src/ui
parentFix for 181473 : Patch for Layers drag and drop crash (diff)
downloadinkscape-49efde87b3c658385e2f06b2b662308b5982c710.tar.gz
inkscape-49efde87b3c658385e2f06b2b662308b5982c710.zip
Fix for 181473 : Layer label edit keyboard shortcuts
(bzr r11532)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/layers.cpp42
-rw-r--r--src/ui/dialog/layers.h3
2 files changed, 34 insertions, 11 deletions
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index 77873e5ec..e8fe6dc08 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -39,7 +39,7 @@
#include "widgets/icon.h"
#include "xml/repr.h"
#include "sp-root.h"
-
+#include "event-context.h"
//#define DUMP_LAYERS 1
@@ -507,40 +507,61 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol )
}
}
-void LayersPanel::_handleButtonEvent(GdkEventButton* evt)
+bool LayersPanel::_handleKeyEvent(GdkEventKey *event)
+{
+
+ switch (get_group0_keyval(event)) {
+ case GDK_KEY_Return:
+ case GDK_KEY_KP_Enter:
+ case GDK_KEY_F2: {
+ Gtk::TreeModel::iterator iter = _tree.get_selection()->get_selected();
+ if (iter && !_text_renderer->property_editable()) {
+ Gtk::TreeModel::Path *path = new Gtk::TreeModel::Path(iter);
+ // Edit the layer label
+ _text_renderer->property_editable() = true;
+ _tree.set_cursor(*path, *_name_column, true);
+ grab_focus();
+ return true;
+ }
+ }
+ break;
+ }
+ return false;
+}
+void LayersPanel::_handleButtonEvent(GdkEventButton* event)
{
static unsigned doubleclick = 0;
// TODO - fix to a better is-popup function
- if ( (evt->type == GDK_BUTTON_PRESS) && (evt->button == 3) ) {
+ if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) ) {
{
Gtk::TreeModel::Path path;
Gtk::TreeViewColumn* col = 0;
- int x = static_cast<int>(evt->x);
- int y = static_cast<int>(evt->y);
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
int x2 = 0;
int y2 = 0;
if ( _tree.get_path_at_pos( x, y,
path, col,
x2, y2 ) ) {
_checkTreeSelection();
- _popupMenu.popup(evt->button, evt->time);
+ _popupMenu.popup(event->button, event->time);
}
}
}
- if ( (evt->type == GDK_2BUTTON_PRESS) && (evt->button == 1) ) {
+ if ( (event->type == GDK_2BUTTON_PRESS) && (event->button == 1) ) {
doubleclick = 1;
}
- if ( evt->type == GDK_BUTTON_RELEASE && doubleclick) {
+ if ( event->type == GDK_BUTTON_RELEASE && doubleclick) {
doubleclick = 0;
Gtk::TreeModel::Path path;
Gtk::TreeViewColumn* col = 0;
- int x = static_cast<int>(evt->x);
- int y = static_cast<int>(evt->y);
+ int x = static_cast<int>(event->x);
+ int y = static_cast<int>(event->y);
int x2 = 0;
int y2 = 0;
if ( _tree.get_path_at_pos( x, y, path, col, x2, y2 ) && col == _name_column) {
@@ -758,6 +779,7 @@ LayersPanel::LayersPanel() :
_tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
_tree.signal_button_release_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
+ _tree.signal_key_press_event().connect( sigc::mem_fun(*this, &LayersPanel::_handleKeyEvent), false );
_scroller.add( _tree );
_scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h
index 6d3ea2224..957d61853 100644
--- a/src/ui/dialog/layers.h
+++ b/src/ui/dialog/layers.h
@@ -65,7 +65,8 @@ private:
void _preToggle( GdkEvent const *event );
void _toggled( Glib::ustring const& str, int targetCol );
- void _handleButtonEvent(GdkEventButton* evt);
+ void _handleButtonEvent(GdkEventButton *event);
+ bool _handleKeyEvent(GdkEventKey *event);
void _handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeModel::iterator const& iter );
bool _handleDragDrop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
void _handleEdited(const Glib::ustring& path, const Glib::ustring& new_text);