Beispiel #1
0
void dt_accel_rename_lua(const gchar *path,const gchar *new_path)
{
  dt_accel_t *accel;
  GSList * l = darktable.control->accelerator_list;
  char build_path[1024];
  dt_accel_path_lua(build_path, sizeof(build_path), path);
  while(l)
  {
    accel = (dt_accel_t*)l->data;
    if(accel && !strncmp(accel->path, build_path, 1024))
    {
      GtkAccelKey tmp_key = *(gtk_accel_group_find(darktable.control->accelerators,find_accel_internal,accel->closure));
      dt_accel_deregister_lua(path);
      g_closure_ref(accel->closure);
      dt_accel_register_lua(new_path,tmp_key.accel_key,tmp_key.accel_mods);
      dt_accel_connect_lua(new_path,accel->closure);
      g_closure_unref(accel->closure);
      l = NULL;
    }
    else
    {
      l = g_slist_next(l);
    }
  }
}
Beispiel #2
0
static int register_shortcut_event(lua_State* L) {
  // 1 is the event name (checked)
  // 2 is the action to perform (checked)
  // 3 is the key itself
  int result = register_keyed_event(L); // will raise an error in case of duplicate key
  const char* tmp = luaL_checkstring(L,3);
  dt_accel_register_lua(tmp,0,0);
  dt_accel_connect_lua(tmp, g_cclosure_new(G_CALLBACK(shortcut_callback),strdup(luaL_checkstring(L,3)),closure_destroy));
  return result;
}