Show
Ignore:
Timestamp:
10/23/09 17:58:55 (3 years ago)
Author:
mirko
Message:

Keybindings core.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/clutter-experiments/pdfcube.hh

    r57 r59  
    11#pragma once 
     2 
     3#include <cassert> 
    24 
    35namespace pdfcube { 
     
    9597      g_thread_create(render_thread, this, FALSE, NULL); 
    9698       
     99      clutter_actor_set_reactive(the_stage_m, TRUE); 
     100      g_signal_connect(the_stage_m,  
     101                       "key-press-event", 
     102                       G_CALLBACK (pdfcube::app::keypress_event),  
     103                       NULL); 
    97104      clutter_threads_enter(); 
    98105      clutter_main(); 
     
    174181      clutter_actor_set_size(me->current_page_m, w, h); 
    175182      clutter_container_add_actor(CLUTTER_CONTAINER(me->the_stage_m),  
    176                             me->current_page_m); 
     183                                  me->current_page_m); 
     184 
     185      ClutterBindingPool *binding_pool; 
     186      std::cerr << G_OBJECT_TYPE_NAME(me->the_stage_m) << std::endl; 
     187      binding_pool = clutter_binding_pool_new(G_OBJECT_TYPE_NAME(me->the_stage_m)); 
     188 
     189      clutter_binding_pool_install_action(binding_pool,  
     190                                          "move-up", 
     191                                          CLUTTER_Up, (ClutterModifierType)0, 
     192                                          G_CALLBACK(pdfcube::app::action_move_up), 
     193                                          me,  
     194                                          NULL); 
     195 
     196      clutter_binding_pool_install_action(binding_pool,  
     197                                          "move-up", 
     198                                          CLUTTER_KP_Up, (ClutterModifierType)0, 
     199                                          G_CALLBACK(pdfcube::app::action_move_up), 
     200                                          me,  
     201                                          NULL); 
     202 
    177203      return FALSE; 
    178204    } 
     
    211237    } 
    212238 
     239    ////////////////////////////////////////////////////////////////////// 
     240    // 
     241    // Callbacks 
     242    // 
     243    static gboolean keypress_event(ClutterActor* actor, 
     244                                   ClutterEvent* evt, 
     245                                   gpointer data) 
     246    { 
     247      pdfcube::app* self = (pdfcube::app*)data; 
     248      ClutterKeyEvent* key_evt = (ClutterKeyEvent*)evt; 
     249      ClutterBindingPool *pool = NULL; 
     250       
     251      std::cerr << " * " << G_OBJECT_TYPE_NAME(actor) << std::endl; 
     252      /* retrieve the binding pool for the type of the actor */ 
     253      pool = clutter_binding_pool_find(G_OBJECT_TYPE_NAME(actor)); 
     254       
     255      assert(pool); 
     256      /* activate any callback matching the key symbol and modifiers 
     257       * mask of the key event. the returned value can be directly 
     258       * used to signal that the actor has handled the event. 
     259       */ 
     260      return clutter_binding_pool_activate (pool,  
     261                                            (guint)key_evt->keyval, 
     262                                            (ClutterModifierType)key_evt->modifier_state, 
     263                                            G_OBJECT(actor)); 
     264       
     265    } 
     266 
     267    static gboolean action_move_up(GObject             *instance, 
     268                                   const gchar         *action_name, 
     269                                   guint                key_val, 
     270                                   ClutterModifierType  modifiers, 
     271                                   gpointer             user_data) 
     272    { 
     273      std::cerr << "move-up" << std::endl; 
     274    } 
     275 
     276 
     277 
    213278  }; 
    214279}