Added accel for menubar
authordanigm <dani@danigm.net>
Mon, 23 Aug 2010 21:07:39 +0000 (23:07 +0200)
committerdanigm <dani@danigm.net>
Mon, 23 Aug 2010 21:07:39 +0000 (23:07 +0200)
src/tbo-tool-selector.c
src/ui-menu.c

index 5329e00..a33d3f6 100644 (file)
@@ -43,7 +43,6 @@ static void page_view_on_click (TboToolBase *tool, GtkWidget *widget, GdkEventBu
 static void frame_view_drawing (TboToolBase *tool, cairo_t *cr);
 static void page_view_drawing (TboToolBase *tool, cairo_t *cr);
 static void frame_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event);
-static void page_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event);
 
 /* Definitions */
 
@@ -270,8 +269,6 @@ on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
     Frame *frame = tbo_drawing_get_current_frame (drawing);
     if (frame)
         frame_view_on_key (tool, widget, event);
-    else
-        page_view_on_key (tool, widget, event);
 }
 
 static void
@@ -513,31 +510,15 @@ frame_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
     {
         switch (event->keyval)
         {
-            case GDK_Delete:
-                tbo_frame_del_obj (self->selected_frame, current_obj);
-                tbo_tool_selector_set_selected_obj (self, NULL);
-                break;
-            case GDK_v:
-                tbo_object_base_flipv (current_obj);
-                break;
-            case GDK_h:
-                tbo_object_base_fliph (current_obj);
-                break;
-            case GDK_Page_Up:
-                tbo_object_base_order_up (current_obj, current_frame);
-                break;
-            case GDK_Page_Down:
-                tbo_object_base_order_down (current_obj, current_frame);
-                break;
-            case GDK_Up:
-                tbo_object_base_move (current_obj, MOVE_UP);
-                break;
             case GDK_less:
                 tbo_object_base_resize (current_obj, RESIZE_LESS);
                 break;
             case GDK_greater:
                 tbo_object_base_resize (current_obj, RESIZE_GREATER);
                 break;
+            case GDK_Up:
+                tbo_object_base_move (current_obj, MOVE_UP);
+                break;
             case GDK_Down:
                 tbo_object_base_move (current_obj, MOVE_DOWN);
                 break;
@@ -547,16 +528,6 @@ frame_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
             case GDK_Right:
                 tbo_object_base_move (current_obj, MOVE_RIGHT);
                 break;
-            case GDK_d:
-                if (event->state & GDK_CONTROL_MASK)
-                {
-                    TboObjectBase *cloned_obj = current_obj->clone (current_obj);
-                    cloned_obj->x += 10;
-                    cloned_obj->y -= 10;
-                    tbo_frame_add_obj (self->selected_frame, cloned_obj);
-                    tbo_tool_selector_set_selected_obj (self, cloned_obj);
-                }
-                break;
             default:
                 break;
         }
@@ -564,40 +535,6 @@ frame_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
     tbo_drawing_update (drawing);
 }
 
-/* page view */
-static void
-page_view_on_key (TboToolBase *tool, GtkWidget *widget, GdkEventKey *event)
-{
-    Page *page;
-
-    TboWindow *tbo = tool->tbo;
-    TboToolSelector *self = TBO_TOOL_SELECTOR (tool);
-    page = tbo_comic_get_current_page (tbo->comic);
-    Frame *selected = self->selected_frame;
-
-    if (selected != NULL && event->keyval == GDK_Delete)
-    {
-        tbo_page_del_frame (page, selected);
-        tbo_tool_selector_set_selected (self, NULL);
-    }
-
-    switch (event->keyval)
-    {
-        case GDK_d:
-            if ((event->state & GDK_CONTROL_MASK) && selected)
-            {
-                Frame *cloned_frame = tbo_frame_clone (selected);
-                cloned_frame->x += 10;
-                cloned_frame->y -= 10;
-                tbo_page_add_frame (page, cloned_frame);
-                tbo_tool_selector_set_selected (self, cloned_frame);
-            }
-            break;
-        default:
-            break;
-    }
-}
-
 static void
 page_view_drawing (TboToolBase *tool, cairo_t *cr)
 {
index 3755732..9235203 100644 (file)
@@ -99,6 +99,7 @@ clone_obj_cb (GtkWidget *widget, TboWindow *tbo)
         cloned_frame->x += 10;
         cloned_frame->y -= 10;
         tbo_page_add_frame (page, cloned_frame);
+        tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_SELECTOR);
         tbo_tool_selector_set_selected (selector, cloned_frame);
     }
     else if (obj && tbo_drawing_get_current_frame (drawing))
@@ -107,6 +108,7 @@ clone_obj_cb (GtkWidget *widget, TboWindow *tbo)
         cloned_obj->x += 10;
         cloned_obj->y -= 10;
         tbo_frame_add_obj (frame, cloned_obj);
+        tbo_toolbar_set_selected_tool (tbo->toolbar, TBO_TOOLBAR_SELECTOR);
         tbo_tool_selector_set_selected_obj (selector, cloned_obj);
     }
     tbo_drawing_update (TBO_DRAWING (tbo->drawing));
@@ -301,6 +303,7 @@ static const GtkActionEntry tbo_menu_entries [] = {
 GtkWidget *generate_menu (TboWindow *window){
     GtkWidget *menu;
     GtkUIManager *manager;
+    GtkAccelGroup *accel;
     GError *error = NULL;
 
     manager = gtk_ui_manager_new ();
@@ -320,6 +323,9 @@ GtkWidget *generate_menu (TboWindow *window){
 
     menu = gtk_ui_manager_get_widget (manager, "/menubar");
 
+    accel = gtk_ui_manager_get_accel_group (manager);
+    gtk_window_add_accel_group (GTK_WINDOW (window->window), accel);
+
     return menu;
 }