Code

implement select next/prev as verbs
authorbuliabyak <buliabyak@users.sourceforge.net>
Mon, 6 Nov 2006 05:46:26 +0000 (05:46 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Mon, 6 Nov 2006 05:46:26 +0000 (05:46 +0000)
src/event-context.cpp
src/node-context.cpp
src/select-context.cpp
src/verbs.cpp
src/verbs.h

index 42557abdca71a990a428f04d82a82817eda3ddd2..47447e6a0fa4263a6c10e3b09158156529a4f20d 100644 (file)
@@ -479,9 +479,13 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
             break;
         case GDK_KEY_PRESS:
             switch (get_group0_keyval(&event->key)) {
+                // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
+                // in the editing window). So we resteal them back and run our regular shortcut
+                // invoker on them.
                 unsigned int shortcut;
+                case GDK_Tab: 
+                case GDK_ISO_Left_Tab: 
                 case GDK_F1:
-                    /* Grab it away from Gtk */
                     shortcut = get_group0_keyval(&event->key);
                     if (event->key.state & GDK_SHIFT_MASK)
                         shortcut |= SP_SHORTCUT_SHIFT_MASK;
@@ -492,22 +496,6 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                     ret = sp_shortcut_invoke(shortcut, desktop);
                     break;
 
-                case GDK_Tab: // disable tab/shift-tab which cycle widget focus
-                case GDK_ISO_Left_Tab: // they will get different functions
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        ret = TRUE;
-                    } else {
-                        /* Grab it away from Gtk */
-                        shortcut = get_group0_keyval(&event->key);
-                        if (event->key.state & GDK_SHIFT_MASK)
-                            shortcut |= SP_SHORTCUT_SHIFT_MASK;
-                        if (event->key.state & GDK_CONTROL_MASK)
-                            shortcut |= SP_SHORTCUT_CONTROL_MASK;
-                        if (event->key.state & GDK_MOD1_MASK)
-                            shortcut |= SP_SHORTCUT_ALT_MASK;
-                        ret = sp_shortcut_invoke(shortcut, desktop);
-                    }
-                    break;
                 case GDK_W:
                 case GDK_w:
                 case GDK_F4:
index e6ea78c624a16e00b763fe8724b9052be42d8606..439848d5222c6604ad428e0bb3bf8f3daa21b400 100644 (file)
@@ -812,18 +812,6 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         ret = TRUE;
                     }
                     break;
-                case GDK_Tab: // Tab - cycle selection forward
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        sp_nodepath_select_next(nc->nodepath);
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_ISO_Left_Tab:  // Shift Tab - cycle selection backward
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        sp_nodepath_select_prev(nc->nodepath);
-                        ret = TRUE;
-                    }
-                    break;
                 case GDK_Escape:
                 {
                     NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
index 35b1aded580a55aedaf3daa703f6af9a6b2c076f..96a9f741bd0d9a61d675703877780a6dd12b873b 100644 (file)
@@ -736,18 +736,6 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         ret = TRUE;
                     }
                     break;
-                case GDK_Tab: // Tab - cycle selection forward
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        sp_selection_item_next();
-                        ret = TRUE;
-                    }
-                    break;
-                case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
-                    if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
-                        sp_selection_item_prev();
-                        ret = TRUE;
-                    }
-                    break;
                 case GDK_space:
                     /* stamping mode: show outline mode moving */
                     /* FIXME: Is next condition ok? (lauris) */
index da843bbe841b35e5a1eb01c4ae7c3d944c3d5f55..1495c1f9e32db4e23e3dcf106883c24be61dbc72 100644 (file)
@@ -846,7 +846,6 @@ EditVerb::perform(SPAction *action, void *data, void *pdata)
     SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
     if (!dt)
         return;
-
     SPEventContext *ec = dt->event_context;
 
     switch (reinterpret_cast<std::size_t>(data)) {
@@ -941,6 +940,22 @@ EditVerb::perform(SPAction *action, void *data, void *pdata)
                 sp_edit_invert_in_all_layers();
             }
             break;
+
+        case SP_VERB_EDIT_SELECT_NEXT: 
+            if (tools_isactive(dt, TOOLS_NODES)) {
+                sp_nodepath_select_next(SP_NODE_CONTEXT(ec)->nodepath);
+            } else {
+                sp_selection_item_next();
+            }
+            break;
+        case SP_VERB_EDIT_SELECT_PREV: 
+            if (tools_isactive(dt, TOOLS_NODES)) {
+                sp_nodepath_select_prev(SP_NODE_CONTEXT(ec)->nodepath);
+            } else {
+                sp_selection_item_prev();
+            }
+            break;
+
         case SP_VERB_EDIT_DESELECT:
             if (tools_isactive(dt, TOOLS_NODES)) {
                 sp_nodepath_deselect(SP_NODE_CONTEXT(ec)->nodepath);
@@ -2027,6 +2042,10 @@ Verb *Verb::_base_verbs[] = {
                  N_("Invert selection (unselect what is selected and select everything else)"), "selection_invert"),
     new EditVerb(SP_VERB_EDIT_INVERT_IN_ALL_LAYERS, "EditInvertInAllLayers", N_("Invert in All Layers"),
                  N_("Invert selection in all visible and unlocked layers"), NULL),
+    new EditVerb(SP_VERB_EDIT_SELECT_NEXT, "EditSelectNext", N_("Select Next"),
+                 N_("Select next object or node"), NULL),
+    new EditVerb(SP_VERB_EDIT_SELECT_PREV, "EditSelectPrev", N_("Select Previous"),
+                 N_("Select previous object or node"), NULL),
     new EditVerb(SP_VERB_EDIT_DESELECT, "EditDeselect", N_("D_eselect"),
                  N_("Deselect any selected objects or nodes"), "selection_deselect"),
 
index f20806c02364229ae1595f9f5ce315eedf82fd24..7567deefa61d43e4b4d4d454c07a73a5e768417f 100644 (file)
@@ -71,6 +71,8 @@ enum {
     SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS,
     SP_VERB_EDIT_INVERT,
     SP_VERB_EDIT_INVERT_IN_ALL_LAYERS,
+    SP_VERB_EDIT_SELECT_NEXT,
+    SP_VERB_EDIT_SELECT_PREV,
     SP_VERB_EDIT_DESELECT,
     /* Selection */
     SP_VERB_SELECTION_TO_FRONT,